Update Bot (j'ai plus le repo sur GitHub)
Qui c'est la conne qui a delete le repo sur GitHub? C'EST MOIIIII
This commit is contained in:
@@ -1,37 +1,40 @@
|
||||
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js');
|
||||
const { SlashCommandBuilder, PermissionFlagsBits, MessageFlags } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
category: 'dev',
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('reload')
|
||||
.setDescription('Reloads a command.')
|
||||
.setDescription('Recharge une commande.')
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addStringOption(option =>
|
||||
option.setName('command')
|
||||
.setDescription('The command to reload.')
|
||||
.setDescription('La commande à recharger.')
|
||||
.setRequired(true)),
|
||||
async execute(interaction) {
|
||||
if (!interaction.member.permissions.has(PermissionFlagsBits.Administrator)) {
|
||||
return interaction.reply({ content: '❌ Only administrators can use this command.', embeds: [embed] });
|
||||
return interaction.reply({ content: '❌ Seuls les administrateurs peuvent utiliser cette commande.', flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
|
||||
|
||||
const commandName = interaction.options.getString('command', true).toLowerCase();
|
||||
const command = interaction.client.commands.get(commandName);
|
||||
|
||||
if (!command) {
|
||||
return interaction.reply({ content: `There is no command with name \`${commandName}\`!`, embeds: [embed] });
|
||||
return interaction.reply({ content: `❌ Aucune commande nommée \`${commandName}\` n'a été trouvée !`, flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
|
||||
delete require.cache[require.resolve(`../${command.category}/${command.data.name}.js`)];
|
||||
|
||||
try {
|
||||
const newCommand = require(`../${command.category}/${command.data.name}.js`);
|
||||
// Supprimer du cache
|
||||
const commandPath = `../${command.category}/${command.data.name}.js`;
|
||||
delete require.cache[require.resolve(commandPath)];
|
||||
|
||||
// Recharger
|
||||
const newCommand = require(commandPath);
|
||||
interaction.client.commands.set(newCommand.data.name, newCommand);
|
||||
await interaction.reply({ content: `✅ Command \`${newCommand.data.name}\` was reloaded!`, });
|
||||
|
||||
await interaction.reply({ content: `✅ Commande \`${newCommand.data.name}\` rechargée avec succès !`, flags: MessageFlags.Ephemeral });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await interaction.reply({ content: `❌ Error while reloading \`${command.data.name}\`:\n\`${error.message}\``, embeds: [embed] });
|
||||
await interaction.reply({ content: `❌ Erreur lors du rechargement de \`${command.data.name}\`:\n\`${error.message}\``, flags: MessageFlags.Ephemeral });
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user