JaBa/commands/Owner/reload.js

81 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"),
2023-06-26 17:25:17 +05:00
i18next = require("i18next");
2023-07-05 00:58:06 +05:00
// autoUpdateDocs = require("../../helpers/autoUpdateDocs");
class Reload extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("reload")
.setDescription(client.translate("owner/reload:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("owner/reload:DESCRIPTION", null, "uk-UA"),
ru: client.translate("owner/reload:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(true)
2023-07-05 00:58:06 +05:00
.addStringOption(option =>
option
.setName("command")
.setDescription(client.translate("common:COMMAND"))
.setDescriptionLocalizations({
uk: client.translate("common:COMMAND", null, "uk-UA"),
ru: client.translate("common:COMMAND", null, "ru-RU"),
})
.setRequired(true)
.setAutocomplete(true),
),
dirname: __dirname,
ownerOnly: true,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
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 });
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);
interaction.success("owner/reload:SUCCESS", {
command: cmd.command.name,
}, { ephemeral: true });
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} 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));
2024-01-15 23:19:59 +05:00
return await interaction.respond(
2023-07-05 00:58:06 +05:00
results
.map(c => c)
.slice(0, 25)
.map(c => ({
name: c.command.name,
value: c.command.name,
})),
);
}
}
2023-07-05 00:58:06 +05:00
module.exports = Reload;