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