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