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:
@ -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,
|
||||
};
|
||||
|
||||
16
src/events/interactionCreate.ts
Normal file
16
src/events/interactionCreate.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user