1 |
import { ModalSubmitInteraction } from 'discord-modals'; |
2 |
import { PermissionResolvable, 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 |
permissions: PermissionResolvable[] = []; |
15 |
|
16 |
constructor(private name: string, private category: string, private aliases: Array<string>) { |
17 |
|
18 |
} |
19 |
|
20 |
getName(): string { |
21 |
return this.name; |
22 |
} |
23 |
|
24 |
getCategory(): string { |
25 |
return this.category; |
26 |
} |
27 |
|
28 |
getAliases(): Array<string> { |
29 |
return this.aliases; |
30 |
} |
31 |
|
32 |
async autoComplete(client: DiscordClient, interaction: AutocompleteInteraction, options: AutoCompleteOptions): Promise <void> { |
33 |
|
34 |
} |
35 |
|
36 |
async default(client: DiscordClient, interaction: Interaction): Promise <void> { |
37 |
|
38 |
} |
39 |
|
40 |
async modalSubmit(client: DiscordClient, interaction: ModalSubmitInteraction): Promise <void> { |
41 |
|
42 |
} |
43 |
|
44 |
async deferReply(msg: Message | CommandInteraction | ContextMenuInteraction, options: MessageOptions | string | MessagePayload | WebhookEditMessageOptions, edit: boolean = false): Promise<Message | CommandInteraction> { |
45 |
if (msg instanceof Message) { |
46 |
return await msg[edit ? 'edit' : 'reply'](options as (MessageOptions & MessageEditOptions)); |
47 |
} |
48 |
|
49 |
return (await msg.editReply(options as string | MessagePayload | WebhookEditMessageOptions)) as Message; |
50 |
} |
51 |
|
52 |
abstract run(client: DiscordClient, message: Message | Interaction, options: CommandOptions | InteractionOptions): Promise<void>; |
53 |
} |