Files
drb-server/discordBot/events/interactionCreate.mjs
Logan Cusano 117cbea67f
All checks were successful
release-tag / release-image (push) Successful in 1m52s
Lint JavaScript/Node.js / lint-js (push) Successful in 11s
DRB Tests / drb_mocha_tests (push) Successful in 29s
Linting
2024-08-11 15:57:46 -04:00

37 lines
1.1 KiB
JavaScript

import { DebugBuilder } from "../../modules/debugger.mjs";
const log = new DebugBuilder("server", "discordBot.events.interactionCreate");
import { Events } from "discord.js";
export const name = Events.InteractionCreate;
export async function execute(nodeIo, interaction) {
const command = interaction.client.commands.get(interaction.commandName);
log.INFO("Interaction created for command: ", command);
// Execute autocomplete if the user is checking autocomplete
if (interaction.isAutocomplete()) {
log.INFO("Running autocomplete for command: ", command.data.name);
return await command.autocomplete(nodeIo, interaction);
}
// Check if the interaction is a command
if (!interaction.isChatInputCommand()) return;
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
log.INFO(
`${interaction.member.user} is running '${interaction.commandName}'`,
);
// Defer the initial reply if the command has the parameter set
if (command.deferInitialReply) {
await interaction.deferReply();
}
// Execute the command
command.execute(nodeIo, interaction);
}