Initial move
This commit is contained in:
32
discordBot/events/interactionCreate.mjs
Normal file
32
discordBot/events/interactionCreate.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
import { Events } from 'discord.js';
|
||||
|
||||
export const name = Events.InteractionCreate;
|
||||
|
||||
export async function execute(nodeIo, interaction) {
|
||||
const command = interaction.client.commands.get(interaction.commandName);
|
||||
console.log("Interaction created for command: ", command);
|
||||
|
||||
// Execute autocomplete if the user is checking autocomplete
|
||||
if (interaction.isAutocomplete()) {
|
||||
console.log("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;
|
||||
}
|
||||
|
||||
console.log(`${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);
|
||||
}
|
||||
Reference in New Issue
Block a user