2022-07-31 17:08:00 +05:00
|
|
|
const { SlashCommandBuilder } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand"),
|
2023-06-26 17:25:17 +05:00
|
|
|
i18next = require("i18next");
|
|
|
|
// autoUpdateDocs = require("../../helpers/autoUpdateDocs");
|
2022-07-26 19:46:32 +05:00
|
|
|
|
|
|
|
class Reload extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("reload")
|
|
|
|
.setDescription(client.translate("owner/reload:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("owner/reload:DESCRIPTION", null, "uk-UA"),
|
|
|
|
"ru": client.translate("owner/reload:DESCRIPTION", null, "ru-RU"),
|
|
|
|
})
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(true)
|
2022-08-04 19:26:17 +05:00
|
|
|
.addStringOption(option => option.setName("command")
|
2022-12-07 18:43:20 +05:00
|
|
|
.setDescription(client.translate("common:COMMAND"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
|
|
|
"uk": client.translate("common:COMMAND", null, "uk-UA"),
|
|
|
|
"ru": client.translate("common:COMMAND", null, "ru-RU"),
|
|
|
|
})
|
2023-03-26 18:31:19 +05:00
|
|
|
.setRequired(true)
|
|
|
|
.setAutocomplete(true)),
|
2022-07-26 19:46:32 +05:00
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: true,
|
2022-07-26 19:46:32 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
async onLoad() {
|
|
|
|
//...
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
2022-08-01 20:06:09 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
2022-08-09 23:48:33 +05:00
|
|
|
* @param {Object} data
|
2022-07-26 19:46:32 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
2023-01-09 01:39:13 +05:00
|
|
|
const command = interaction.options.getString("command"),
|
|
|
|
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 });
|
2022-07-26 19:46:32 +05:00
|
|
|
|
|
|
|
await client.unloadCommand(`../commands/${cmd.category}`, cmd.command.name);
|
|
|
|
await client.loadCommand(`../commands/${cmd.category}`, cmd.command.name);
|
|
|
|
|
2023-06-06 22:59:47 +05:00
|
|
|
i18next.reloadResources(["ru-RU", "uk-UA", "en-US"]);
|
2023-06-26 17:25:17 +05:00
|
|
|
// autoUpdateDocs.update(client);
|
2022-07-26 19:46:32 +05:00
|
|
|
|
|
|
|
interaction.success("owner/reload:SUCCESS", {
|
2022-12-15 21:02:38 +05:00
|
|
|
command: cmd.command.name,
|
2022-07-29 23:31:08 +05:00
|
|
|
}, { ephemeral: true });
|
2022-07-26 19:46:32 +05:00
|
|
|
}
|
2023-03-26 18:31:19 +05:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
* @param {import("discord.js").AutocompleteInteraction} interaction
|
|
|
|
* @returns
|
|
|
|
*/
|
|
|
|
async autocompleteRun(client, interaction) {
|
|
|
|
const command = interaction.options.getString("command"),
|
|
|
|
results = client.commands.filter(c => c.command.name.includes(command));
|
|
|
|
|
|
|
|
return interaction.respond(
|
|
|
|
results.map(c => c).slice(0, 25).map(c => ({
|
|
|
|
name: c.command.name,
|
|
|
|
value: c.command.name,
|
|
|
|
}),
|
|
|
|
));
|
|
|
|
}
|
2022-07-26 19:46:32 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Reload;
|