1
1
mirror of https://github.com/Burn-E99/GroupUp.git synced 2026-06-04 08:53:49 -04:00

Add button systems, add game selection, add initial details modal

This commit is contained in:
Ean Milligan (Bastion)
2023-01-31 03:32:53 -05:00
parent 5303a20234
commit d712b116b6
9 changed files with 221 additions and 32 deletions

View File

@@ -1,16 +1,30 @@
import { Bot, BotWithCache, Interaction } from '../../deps.ts';
import { commands } from '../commands/_index.ts';
import { Button } from '../types/commandTypes.ts';
import { createEventButton } from '../buttons/event-creation/step1-gameSelection.ts';
const buttons: Array<Button> = [createEventButton];
const commandNames: Array<string> = commands.map((command) => command.details.name);
const buttonNames: Array<string> = buttons.map((button) => button.customId);
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);
}
if (interaction.data.name && commandNames.includes(interaction.data.name)) {
const cmdIdx = commandNames.indexOf(interaction.data.name);
commands[cmdIdx].execute(bot, interaction);
return;
}
const customId = interaction.data.customId ? interaction.data.customId.replace(/\$/g, '') : ''
if (customId && buttonNames.includes(customId)) {
const btnIdx = buttonNames.indexOf(customId);
buttons[btnIdx].execute(bot, interaction);
return;
}
console.log('interaction NOT HANDLED')
}
};