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