add structure for simplifie creation of global command

This commit is contained in:
Arthur Puechberty
2026-01-17 15:13:22 +01:00
parent 08647924e3
commit d5f0f4c30b
11 changed files with 593 additions and 17 deletions
+46
View File
@@ -0,0 +1,46 @@
module.exports = {
name: "interactionCreate",
async execute(client, interaction) {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
if (command.dm !== true && interaction.channel.type === 1)
return interaction.reply({
content: "Cette commande ne peut pas être utilisée en message privé.",
ephemeral: true,
});
if (process.env.OWNER && !process.env.OWNER === interaction.user.id) {
if (command.botOwnerOnly)
return interaction.reply({
content: "Cette commande est réservée au propriétaire du bot.",
ephemeral: true,
});
if (
command.permissions &&
interaction.channel.type !== 1 &&
!command.permissions.every((permission) =>
interaction.member.permissions.has(permission),
)
)
return interaction.reply({
content: "Vous n'avez pas la permission d'utiliser cette commande.",
ephemeral: true,
});
}
try {
command.executeSlash(client, interaction);
console.log(
`[CMD - SLASH] ${interaction.user.tag} | ${interaction.commandName}`,
);
} catch (error) {
console.error(
`Erreur lors de l'exécution de la commande slash '${interaction.commandName}':`,
error,
);
}
},
};