eximiabots-radiox/src/client/events/interactionCreate.js
2023-05-24 00:48:29 +03:00

46 lines
1.6 KiB
JavaScript

import { PermissionFlagsBits } from "discord.js";
module.exports = {
name: 'interactionCreate',
async execute(client, interaction) {
const permissions = interaction.channel.permissionsFor(interaction.client.user);
if (!permissions.has(PermissionFlagsBits.ViewChannel)) return;
if (!permissions.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({
content: client.messageEmojis["error"] + client.messages.noPermsEmbed,
ephemeral: true
});
if(interaction.isChatInputCommand()){
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.isStringSelectMenu() || 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);
}
}
}
}