mirror of
https://github.com/warengroup/eximiabots-radiox.git
synced 2025-07-02 00:23:38 +00:00
Simplify events
This commit is contained in:
@ -1,53 +1,52 @@
|
||||
import { PermissionFlagsBits } from "discord.js";
|
||||
import { Interaction, PermissionFlagsBits } from "discord.js";
|
||||
import RadioClient from "../../Client";
|
||||
|
||||
export default {
|
||||
name: 'interactionCreate',
|
||||
async execute(client: RadioClient, interaction: any) {
|
||||
export default function interactionCreate(client: RadioClient, interaction: Interaction) {
|
||||
if(!(interaction.isButton()) && !(interaction.isChatInputCommand()) && !(interaction.isStringSelectMenu())) return;
|
||||
|
||||
if(client.config.maintenanceMode){
|
||||
return interaction.reply({
|
||||
content: client.messages.emojis["error"] + client.messages.maintenance,
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
const permissions = interaction.channel.permissionsFor(interaction.client.user);
|
||||
if (!permissions.has(PermissionFlagsBits.ViewChannel)) return;
|
||||
|
||||
if (!permissions.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({
|
||||
content: client.messages.emojis["error"] + client.messages.noPermsEmbed,
|
||||
if(client.config.maintenanceMode){
|
||||
return interaction.reply({
|
||||
content: client.messages.emojis["error"] + client.messages.maintenance,
|
||||
ephemeral: true
|
||||
});
|
||||
}
|
||||
|
||||
if(interaction.isChatInputCommand()){
|
||||
const commandName = interaction.commandName;
|
||||
const command = client.commands.get(commandName);
|
||||
if (!command) return;
|
||||
//@ts-ignore
|
||||
const permissions = interaction.channel?.permissionsFor(interaction.client.user);
|
||||
if (!permissions.has(PermissionFlagsBits.ViewChannel)) return;
|
||||
|
||||
try {
|
||||
command.execute(interaction, client);
|
||||
} catch (error) {
|
||||
interaction.reply({
|
||||
content: client.messages.emojis["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;
|
||||
if (!permissions.has(PermissionFlagsBits.EmbedLinks)) return interaction.reply({
|
||||
content: client.messages.emojis["error"] + client.messages.noPermsEmbed,
|
||||
ephemeral: true
|
||||
});
|
||||
|
||||
try {
|
||||
command.execute(interaction, client, command);
|
||||
} catch (error) {
|
||||
interaction.reply({
|
||||
content: client.messages.emojis["error"] + client.messages.runningCommandFailed,
|
||||
ephemeral: true
|
||||
});
|
||||
console.error(error);
|
||||
}
|
||||
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.messages.emojis["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.messages.emojis["error"] + client.messages.runningCommandFailed,
|
||||
ephemeral: true
|
||||
});
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user