/[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 58 - (show annotations)
Mon Jul 29 17:28:25 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 1447 byte(s)
Added debug info support and startup manager
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 coolDown?: number;
10 ownerOnly: boolean = false;
11
12 constructor(private name: string, private category: string, private aliases: Array<string>) {
13
14 }
15
16 getName(): string {
17 return this.name;
18 }
19
20 getCategory(): string {
21 return this.category;
22 }
23
24 getAliases(): Array<string> {
25 return this.aliases;
26 }
27
28 async deferReply(msg: Message | CommandInteraction, options: MessageOptions | string | MessagePayload | WebhookEditMessageOptions, edit: boolean = false): Promise<Message | CommandInteraction> {
29 if (msg instanceof Message) {
30 return await msg[edit ? 'edit' : 'reply'](options as (MessageOptions & MessageEditOptions));
31 }
32
33 return (await msg.editReply(options as string | MessagePayload | WebhookEditMessageOptions)) as Message;
34 }
35
36 abstract run(client: DiscordClient, message: Message | Interaction, options: CommandOptions | InteractionOptions): Promise<void>;
37 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26