/[sudobot]/branches/2.x/src/commands/settings/SetStatusCommand.ts
ViewVC logotype

Contents of /branches/2.x/src/commands/settings/SetStatusCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 577 - (show annotations)
Mon Jul 29 18:52:37 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1920 byte(s)
chore: add old version archive branches (2.x to 9.x-dev)
1 import { ActivityType, ClientPresenceStatus, CommandInteraction, ExcludeEnum, GuildMember, Interaction, Message, PresenceStatus, PresenceStatusData } from 'discord.js';
2 import BaseCommand from '../../utils/structures/BaseCommand';
3 import DiscordClient from '../../client/Client';
4 import CommandOptions from '../../types/CommandOptions';
5 import InteractionOptions from '../../types/InteractionOptions';
6 import MessageEmbed from '../../client/MessageEmbed';
7 import { ActivityTypes } from 'discord.js/typings/enums';
8 import { fetchEmoji } from '../../utils/Emoji';
9
10 export default class SetStatusCommand extends BaseCommand {
11 supportsInteractions: boolean = true;
12 ownerOnly = true;
13
14 constructor() {
15 super('setstatus', 'settings', []);
16 }
17
18 async run(client: DiscordClient, message: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {
19 if (!options.isInteraction && options.args[0] === undefined) {
20 await message.reply({
21 content: 'This command requires at least one argument'
22 });
23
24 return;
25 }
26
27 let status: ClientPresenceStatus | undefined;
28 let activity: string;
29 let type: ExcludeEnum<typeof ActivityTypes, 'CUSTOM'> = 'WATCHING';
30
31 if (options.isInteraction) {
32 activity = <string> options.options.getString('activity');
33
34 if (options.options.getString('status'))
35 status = <ClientPresenceStatus> options.options.getString('status');
36
37 if (options.options.getString('type'))
38 type = <typeof type> options.options.getString('type');
39 }
40 else {
41 activity = options.args.join(' ');
42 }
43
44 await client.randomStatus.update(activity, type, status);
45
46 await message.reply({
47 content: (await fetchEmoji('check'))?.toString() + ' Status updated.'
48 });
49 }
50 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26