2024-09-14 19:52:56 +05:00
|
|
|
const { SlashCommandBuilder, InteractionContextType } = require("discord.js");
|
2022-07-31 17:08:00 +05:00
|
|
|
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");
|
2022-07-26 19:46:32 +05:00
|
|
|
|
|
|
|
class Reload extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../base/Client")} client
|
2022-07-26 19:46:32 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("reload")
|
|
|
|
.setDescription(client.translate("owner/reload:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.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"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2024-09-14 19:52:56 +05:00
|
|
|
.setContexts([InteractionContextType.BotDM, InteractionContextType.PrivateChannel, InteractionContextType.Guild])
|
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),
|
|
|
|
),
|
2022-07-26 19:46:32 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: true,
|
2022-07-26 19:46:32 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-07-26 19:46:32 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-01 20:06:09 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
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
|
|
|
|
2024-09-14 19:52:56 +05:00
|
|
|
client.unloadCommand(`../commands/${cmd.category}`, cmd.command.name);
|
|
|
|
|
2022-07-26 19:46:32 +05:00
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2023-03-26 18:31:19 +05:00
|
|
|
* @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-03-26 18:31:19 +05:00
|
|
|
}
|
2022-07-26 19:46:32 +05:00
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Reload;
|