JaBa/commands/Owner/reload.js

55 lines
1.5 KiB
JavaScript
Raw Normal View History

const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"),
i18next = require("i18next"),
autoUpdateDocs = require("../../helpers/autoUpdateDocs");
class Reload extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("reload")
.setDescription(client.translate("owner/reload:DESCRIPTION"))
.addStringOption(option => option.setName("command")
.setDescription(client.translate("owner/reload:COMMAND"))
.setRequired(true)),
aliases: [],
dirname: __dirname,
guildOnly: true,
ownerOnly: true
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
2022-08-09 23:48:33 +05:00
* @param {Object} data
*/
async execute(client, interaction) {
const command = interaction.options.getString("command");
const cmd = client.commands.get(command);
2022-08-14 23:09:26 +05:00
if (!cmd) return interaction.error("owner/reload:NOT_FOUND", { command }, { ephemeral: true });
await client.unloadCommand(`../commands/${cmd.category}`, cmd.command.name);
await client.loadCommand(`../commands/${cmd.category}`, cmd.command.name);
i18next.reloadResources(["ru-RU", "uk-UA"]);
autoUpdateDocs.update(client);
interaction.success("owner/reload:SUCCESS", {
command: cmd.command.name
}, { ephemeral: true });
}
}
module.exports = Reload;