1 |
rakin |
64 |
import { AutocompleteInteraction, CommandInteraction, CommandInteractionOption, Interaction, Message, MessageEditOptions, MessageOptions, MessagePayload, WebhookEditMessageOptions } from 'discord.js'; |
2 |
rakin |
51 |
import DiscordClient from '../../client/Client'; |
3 |
rakin |
64 |
import AutoCompleteOptions from '../../types/AutoCompleteOptions'; |
4 |
rakin |
51 |
import CommandOptions from '../../types/CommandOptions'; |
5 |
|
|
import InteractionOptions from '../../types/InteractionOptions'; |
6 |
|
|
|
7 |
|
|
export default abstract class BaseCommand { |
8 |
|
|
supportsInteractions: boolean = false; |
9 |
|
|
supportsLegacy: boolean = true; |
10 |
rakin |
56 |
coolDown?: number; |
11 |
rakin |
58 |
ownerOnly: boolean = false; |
12 |
rakin |
51 |
|
13 |
|
|
constructor(private name: string, private category: string, private aliases: Array<string>) { |
14 |
|
|
|
15 |
|
|
} |
16 |
|
|
|
17 |
|
|
getName(): string { |
18 |
|
|
return this.name; |
19 |
|
|
} |
20 |
|
|
|
21 |
|
|
getCategory(): string { |
22 |
|
|
return this.category; |
23 |
|
|
} |
24 |
|
|
|
25 |
|
|
getAliases(): Array<string> { |
26 |
|
|
return this.aliases; |
27 |
|
|
} |
28 |
|
|
|
29 |
rakin |
64 |
async autoComplete(client: DiscordClient, interaction: AutocompleteInteraction, options: AutoCompleteOptions): Promise <void> { |
30 |
|
|
|
31 |
|
|
} |
32 |
|
|
|
33 |
rakin |
51 |
async deferReply(msg: Message | CommandInteraction, options: MessageOptions | string | MessagePayload | WebhookEditMessageOptions, edit: boolean = false): Promise<Message | CommandInteraction> { |
34 |
|
|
if (msg instanceof Message) { |
35 |
|
|
return await msg[edit ? 'edit' : 'reply'](options as (MessageOptions & MessageEditOptions)); |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
return (await msg.editReply(options as string | MessagePayload | WebhookEditMessageOptions)) as Message; |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
abstract run(client: DiscordClient, message: Message | Interaction, options: CommandOptions | InteractionOptions): Promise<void>; |
42 |
|
|
} |