/[sudobot]/trunk/src/utils/structures/BaseCommand.ts
ViewVC logotype

Contents of /trunk/src/utils/structures/BaseCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 51 - (show annotations)
Mon Jul 29 17:28:23 2024 UTC (8 months, 2 weeks ago) by rakin
File MIME type: application/typescript
File size: 1392 byte(s)
Release version 2.0
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 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26