eximiabots-radiox/src/client/events/interactionCreate.js
2021-09-02 12:54:39 +03:00

42 lines
1.4 KiB
JavaScript

import Discord from "discord.js";
module.exports = {
name: 'interactionCreate',
async execute(client, interaction) {
/*if (!interaction.isCommand()) return;*/
const permissions = interaction.channel.permissionsFor(interaction.client.user);
if (!permissions.has('EMBED_LINKS')) return interaction.send(client.messages.noPermsEmbed);
if(interaction.isCommand()){
const commandName = interaction.commandName;
const command = client.commands.get(commandName);
if (!command) return;
try {
command.execute(interaction, client, Discord, command);
} catch (error) {
interaction.reply({
content: 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, Discord, command);
} catch (error) {
interaction.reply({
content: client.messages.runningCommandFailed,
ephemeral: true
});
console.error(error);
}
}
}
}