1 |
rakin |
344 |
import { ClientPresenceStatus, CommandInteraction, ExcludeEnum, Message } from 'discord.js'; |
2 |
rakin |
71 |
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 { ActivityTypes } from 'discord.js/typings/enums'; |
7 |
|
|
import { fetchEmoji } from '../../utils/Emoji'; |
8 |
|
|
|
9 |
|
|
export default class SetStatusCommand extends BaseCommand { |
10 |
|
|
supportsInteractions: boolean = true; |
11 |
|
|
ownerOnly = true; |
12 |
|
|
|
13 |
|
|
constructor() { |
14 |
|
|
super('setstatus', 'settings', []); |
15 |
|
|
} |
16 |
|
|
|
17 |
|
|
async run(client: DiscordClient, message: Message | CommandInteraction, options: CommandOptions | InteractionOptions) { |
18 |
|
|
if (!options.isInteraction && options.args[0] === undefined) { |
19 |
|
|
await message.reply({ |
20 |
|
|
content: 'This command requires at least one argument' |
21 |
|
|
}); |
22 |
|
|
|
23 |
|
|
return; |
24 |
|
|
} |
25 |
|
|
|
26 |
|
|
let status: ClientPresenceStatus | undefined; |
27 |
|
|
let activity: string; |
28 |
|
|
let type: ExcludeEnum<typeof ActivityTypes, 'CUSTOM'> = 'WATCHING'; |
29 |
|
|
|
30 |
|
|
if (options.isInteraction) { |
31 |
|
|
activity = <string> options.options.getString('activity'); |
32 |
|
|
|
33 |
|
|
if (options.options.getString('status')) |
34 |
|
|
status = <ClientPresenceStatus> options.options.getString('status'); |
35 |
|
|
|
36 |
|
|
if (options.options.getString('type')) |
37 |
|
|
type = <typeof type> options.options.getString('type'); |
38 |
|
|
} |
39 |
|
|
else { |
40 |
|
|
activity = options.args.join(' '); |
41 |
|
|
} |
42 |
rakin |
301 |
|
43 |
|
|
await client.randomStatus.config(activity, type); |
44 |
|
|
await client.randomStatus.update(status); |
45 |
rakin |
71 |
|
46 |
|
|
await message.reply({ |
47 |
|
|
content: (await fetchEmoji('check'))?.toString() + ' Status updated.' |
48 |
|
|
}); |
49 |
|
|
} |
50 |
|
|
} |