Files
valorantDiscordBot/commands/reload.js
2022-08-26 18:19:58 +00:00

39 lines
1.1 KiB
JavaScript

'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
};