From 3cc658f27e615ad234485c59909a3e9003ea65af Mon Sep 17 00:00:00 2001 From: GramingFoxTeam Date: Thu, 10 Aug 2023 15:33:38 +0300 Subject: [PATCH] fix(bot-discord): rename unban command name --- apps/bot-discord/src/commands/unban.js | 14 ++--------- apps/bot-discord/src/registerCommands.js | 31 ++++++++++++------------ 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/apps/bot-discord/src/commands/unban.js b/apps/bot-discord/src/commands/unban.js index c4d1dec..1a28c08 100644 --- a/apps/bot-discord/src/commands/unban.js +++ b/apps/bot-discord/src/commands/unban.js @@ -4,24 +4,14 @@ import reportToLogs from '../utils/reportToLogs.js'; export default { data: new SlashCommandBuilder() - .setName('ban') - .setDescription('Ban a member.') + .setName('unban') + .setDescription('Unban a member.') .setDMPermission(false) .addStringOption(option => option .setName('user') .setDescription('The member to ban') .setRequired(true) - ) - .addIntegerOption(option => - option - .setName('dmd') - .setDescription('Amount of days to delete messages') - ) - .addStringOption(option => - option - .setName('reason') - .setDescription('Reason for the ban') ), async execute(_, config, interaction) { if (!checkForPerms(config, interaction.member)) return interaction.reply({ diff --git a/apps/bot-discord/src/registerCommands.js b/apps/bot-discord/src/registerCommands.js index 6c2978c..1cea873 100644 --- a/apps/bot-discord/src/registerCommands.js +++ b/apps/bot-discord/src/registerCommands.js @@ -1,35 +1,36 @@ import { REST, Routes } from 'discord.js'; import { readdirSync, readFileSync } from 'node:fs'; -const configJSON = readFileSync('../config.json', 'utf-8'); +const configJSON = readFileSync('./config.json', 'utf-8'); const config = JSON.parse(configJSON); const commands = []; // Grab all the command files from the commands directory you created earlier const commandFiles = readdirSync('./commands').filter((file) => - file.endsWith('.js') + file.endsWith('.js') ); // Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment for (const file of commandFiles) { - const command = await import(`./commands/${file}`); - commands.push(command.default.data.toJSON()); + const command = await import(`./commands/${file}`); + if (!command.default.data.toJSON) continue; + commands.push(command.default.data.toJSON()); } // Construct and prepare an instance of the REST module const rest = new REST({ version: '10' }).setToken(process.env.DISCORD_TOKEN); try { - console.log( - `Started refreshing ${commands.length} application (/) commands.` - ); + console.log( + `Started refreshing ${commands.length} application (/) commands.` + ); - // The put method is used to fully refresh all commands in the guild with the current set - const data = await rest.put(Routes.applicationCommands(config.discord.botId), { - body: commands - }); + // The put method is used to fully refresh all commands in the guild with the current set + const data = await rest.put(Routes.applicationCommands(config.discord.botId), { + body: commands + }); - console.log(`Successfully reloaded ${data.length} application (/) commands.`); + console.log(`Successfully reloaded ${data.length} application (/) commands.`); } catch (error) { - // And of course, make sure you catch and log any errors! - console.error(error); -} + // And of course, make sure you catch and log any errors! + console.error(error); +} \ No newline at end of file