const { Events, EmbedBuilder } = require('discord.js');
const pool = require('../bot')
const config = require('../config.json')
module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
console.log(`interaction type: ${interaction.type}`);
if (interaction.isChatInputCommand()) {
await handleChatCommand(interaction);
} else if (interaction.isButton()) {
await handleButtonInteraction(interaction);
} else if (interaction.isAutocomplete()) {
await handleAutocomplete(interaction);
}
}
};
async function handleChatCommand(interaction) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
await command.execute(interaction, pool);
console.log(`${interaction.user.username} used a command | ${interaction.commandName}`);
}
async function handleButtonInteraction(interaction) {
if (interaction.customId === 'nextPage') {
//handle buttons. too long and not related to issue
}
}
async function handleAutocomplete(interaction) {
const command = interaction.client.commands.get(interaction.commandName);
await command.autocomplete(interaction).catch(err => {
console.log(err);
});
if (!interaction.deferred && !interaction.replied && interaction.isChatInputCommand()) {
interaction.reply({
content: `uh oh, an error occurred.`,
ephemeral: true
}).catch(console.error);
}
} //added to try to mitigate issue. did not make a difference
const { Events, EmbedBuilder } = require('discord.js');
const pool = require('../bot')
const config = require('../config.json')
module.exports = {
name: Events.InteractionCreate,
async execute(interaction) {
console.log(`interaction type: ${interaction.type}`);
if (interaction.isChatInputCommand()) {
await handleChatCommand(interaction);
} else if (interaction.isButton()) {
await handleButtonInteraction(interaction);
} else if (interaction.isAutocomplete()) {
await handleAutocomplete(interaction);
}
}
};
async function handleChatCommand(interaction) {
const command = interaction.client.commands.get(interaction.commandName);
if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}
await command.execute(interaction, pool);
console.log(`${interaction.user.username} used a command | ${interaction.commandName}`);
}
async function handleButtonInteraction(interaction) {
if (interaction.customId === 'nextPage') {
//handle buttons. too long and not related to issue
}
}
async function handleAutocomplete(interaction) {
const command = interaction.client.commands.get(interaction.commandName);
await command.autocomplete(interaction).catch(err => {
console.log(err);
});
if (!interaction.deferred && !interaction.replied && interaction.isChatInputCommand()) {
interaction.reply({
content: `uh oh, an error occurred.`,
ephemeral: true
}).catch(console.error);
}
} //added to try to mitigate issue. did not make a difference