/[sudobot]/trunk/src/commands/automation/EmbedCommand.ts
ViewVC logotype

Contents of /trunk/src/commands/automation/EmbedCommand.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 260 - (show annotations)
Mon Jul 29 17:29:15 2024 UTC (8 months, 1 week ago) by rakin
File MIME type: application/typescript
File size: 1732 byte(s)
fix: embed commands not working in legacy mode
1 import { CommandInteraction, Message } from 'discord.js';
2 import BaseCommand from '../../utils/structures/BaseCommand';
3 import DiscordClient from '../../client/Client';
4 import CommandOptions from '../../types/CommandOptions';
5 import InteractionOptions from '../../types/InteractionOptions';
6 import { emoji } from '../../utils/Emoji';
7
8 export default class EmbedCommand extends BaseCommand {
9 supportsInteractions: boolean = true;
10 subcommands = ['send', 'schema', 'build'];
11
12 constructor() {
13 super('embed', 'settings', []);
14 }
15
16 async run(client: DiscordClient, message: Message | CommandInteraction, options: CommandOptions | InteractionOptions) {
17 if (!options.isInteraction && options.args[0] === undefined) {
18 await message.reply(`${emoji('error')} No subcommand provided.`);
19 return;
20 }
21
22 if (!options.isInteraction && (options.args[0] === 'send' || options.args[0] === 'schema')) {
23 await message.reply(`${emoji('error')} This command can not be used in legacy mode. Use slash commands instead.`);
24 return;
25 }
26
27 if (!options.isInteraction && !this.subcommands.includes(options.args[0])) {
28 await message.reply(`${emoji('error')} Invalid subcommand provided. Must be one of ${this.subcommands.map(c => `\`${c}\``).join(', ')}.`);
29 return;
30 }
31
32 const subcommand = options.isInteraction ? options.options.getSubcommand() : options.args[0];
33
34 const command = client.commands.get('embed__' + subcommand);
35
36 if (command) {
37 if (!options.isInteraction)
38 options.args.shift();
39 await command.execute(client, message, options);
40 }
41 }
42 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26