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