Add reload command

This commit is contained in:
2022-08-26 18:19:58 +00:00
parent 5d5c3bfa94
commit c2fcab6738

38
commands/reload.js Normal file
View File

@@ -0,0 +1,38 @@
'use strict';
const path = require('path');
const { SlashCommandBuilder } = require('discord.js');
const getCommands = require(path.join(__dirname, '../lib', 'getCommands.js'));
const unregisterCommands = require(path.join(__dirname, '..', 'unregisterCommands.js'));
const registerCommands = require(path.join(__dirname, '..', 'registerCommands.js'));
const data = new SlashCommandBuilder()
.setName('reload')
.setDescription('Reload all commands to the latest version')
.addBooleanOption(option =>
option.setName('full')
.setDescription('Fully re-register the commands with discord?')
);
const execute = async (interaction) => {
await interaction.reply('Fetching commands...');
interaction.client.commands = getCommands();
if (interaction.options.getBoolean('full')) {
await interaction.editReply('Unregistering commands...');
await unregisterCommands();
await interaction.editReply('Registering new commands...');
await registerCommands();
}
await interaction.editReply('Successfully reloaded commands!');
};
module.exports = {
data,
execute
};