eximiabots-radiox/src/client/events/interactionCreate.js
2021-09-16 02:17:14 +03:00

44 lines
1.5 KiB
JavaScript

module.exports = {
name: 'interactionCreate',
async execute(client, interaction) {
const permissions = interaction.channel.permissionsFor(interaction.client.user);
if (!permissions.has('VIEW_CHANNEL')) return;
if (!permissions.has('EMBED_LINKS')) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noPermsEmbed,
ephemeral: true
});
if(interaction.isCommand()){
const commandName = interaction.commandName;
const command = client.commands.get(commandName);
if (!command) return;
try {
command.execute(interaction, client);
} catch (error) {
interaction.reply({
content: client.messageEmojis["error"] + client.messages.runningCommandFailed,
ephemeral: true
});
console.error(error);
}
} else if (interaction.isSelectMenu() || interaction.isButton()){
const commandName = interaction.customId;
const command = client.commands.get(commandName);
if (!command) return;
try {
command.execute(interaction, client, command);
} catch (error) {
interaction.reply({
content: client.messageEmojis["error"] + client.messages.runningCommandFailed,
ephemeral: true
});
console.error(error);
}
}
}
}