1
1
mirror of https://github.com/Burn-E99/GroupUp.git synced 2026-01-07 20:07:54 -05:00

slash command system added

This commit is contained in:
Ean Milligan (Bastion)
2023-01-11 21:21:43 -05:00
parent 3e6168a396
commit e0497b8526
12 changed files with 155 additions and 34 deletions

View File

@ -3,6 +3,7 @@ import { guildCreate } from './guildCreate.ts';
import { guildDelete } from './guildDelete.ts';
import { debug } from './debug.ts';
import { messageCreate } from './messageCreate.ts';
import { interactionCreate } from './interactionCreate.ts';
export default {
ready,
@ -10,4 +11,5 @@ export default {
guildDelete,
debug,
messageCreate,
interactionCreate,
};

View File

@ -0,0 +1,16 @@
import { Bot, BotWithCache, Interaction } from '../../deps.ts';
import { commands } from '../commands/_index.ts';
const commandNames: Array<string> = commands.map((command) => command.details.name);
export const interactionCreate = (rawBot: Bot, interaction: Interaction) => {
const bot = rawBot as BotWithCache;
if (interaction.data && interaction.id) {
if (interaction.data.name) {
if (commandNames.includes(interaction.data.name)) {
const cmdIdx = commandNames.indexOf(interaction.data.name);
commands[cmdIdx].execute(bot, interaction);
}
}
}
};