1 |
rakin |
81 |
import { ModalSubmitInteraction } from 'discord-modals'; |
2 |
rakin |
125 |
import { AutocompleteInteraction, CommandInteraction, CommandInteractionOption, ContextMenuInteraction, 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 |
125 |
supportsContextMenu: boolean = false; |
12 |
rakin |
56 |
coolDown?: number; |
13 |
rakin |
58 |
ownerOnly: boolean = false; |
14 |
rakin |
51 |
|
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 |
rakin |
64 |
async autoComplete(client: DiscordClient, interaction: AutocompleteInteraction, options: AutoCompleteOptions): Promise <void> { |
32 |
|
|
|
33 |
|
|
} |
34 |
|
|
|
35 |
rakin |
81 |
async default(client: DiscordClient, interaction: Interaction): Promise <void> { |
36 |
|
|
|
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
async modalSubmit(client: DiscordClient, interaction: ModalSubmitInteraction): Promise <void> { |
40 |
|
|
|
41 |
|
|
} |
42 |
|
|
|
43 |
rakin |
125 |
async deferReply(msg: Message | CommandInteraction | ContextMenuInteraction, options: MessageOptions | string | MessagePayload | WebhookEditMessageOptions, edit: boolean = false): Promise<Message | CommandInteraction> { |
44 |
rakin |
51 |
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 |
|
|
} |