2024-09-14 19:52:56 +05:00
|
|
|
const { SlashCommandBuilder, PermissionsBitField, InteractionContextType } = require("discord.js");
|
2022-08-08 18:19:56 +05:00
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Setlang extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-08 18:19:56 +05:00
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("setlang")
|
|
|
|
.setDescription(client.translate("administration/setlang:DESCRIPTION"))
|
2023-06-15 19:46:27 +05:00
|
|
|
.setDescriptionLocalizations({
|
2023-07-05 00:58:06 +05:00
|
|
|
uk: client.translate("administration/setlang:DESCRIPTION", null, "uk-UA"),
|
|
|
|
ru: client.translate("administration/setlang:DESCRIPTION", null, "ru-RU"),
|
2023-06-15 19:46:27 +05:00
|
|
|
})
|
2024-09-14 19:52:56 +05:00
|
|
|
.setContexts([InteractionContextType.Guild])
|
2023-07-03 21:13:08 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
2023-07-05 00:58:06 +05:00
|
|
|
.addStringOption(option =>
|
|
|
|
option
|
|
|
|
.setName("language")
|
|
|
|
.setDescription(client.translate("common:LANGUAGE"))
|
|
|
|
.setDescriptionLocalizations({
|
|
|
|
uk: client.translate("common:LANGUAGE", null, "uk-UA"),
|
|
|
|
ru: client.translate("common:LANGUAGE", null, "ru-RU"),
|
|
|
|
})
|
|
|
|
.setRequired(true)
|
|
|
|
.setChoices({ name: "English", value: "en-US" }, { name: "Русский", value: "ru-RU" }, { name: "Українська", value: "uk-UA" }),
|
|
|
|
),
|
2022-08-08 18:19:56 +05:00
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
}
|
2024-02-06 21:45:53 +05:00
|
|
|
|
2022-08-08 18:19:56 +05:00
|
|
|
/**
|
|
|
|
*
|
2023-11-05 16:03:23 +05:00
|
|
|
* @param {import("../../base/Client")} client
|
2022-08-08 18:19:56 +05:00
|
|
|
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
|
|
|
*/
|
2024-02-09 23:26:57 +05:00
|
|
|
async execute(client, interaction) {
|
|
|
|
const guildData = interaction.data.guild,
|
|
|
|
lang = interaction.options.getString("language"),
|
2023-01-09 01:39:13 +05:00
|
|
|
language = client.languages.find(l => l.name === lang);
|
2022-08-08 18:19:56 +05:00
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
guildData.language = language.name;
|
2023-09-25 21:42:43 +05:00
|
|
|
|
2024-02-09 23:26:57 +05:00
|
|
|
await guildData.save();
|
2022-08-08 18:19:56 +05:00
|
|
|
|
|
|
|
return interaction.success("administration/setlang:SUCCESS", {
|
2022-12-15 21:02:38 +05:00
|
|
|
lang: language.nativeName,
|
2022-08-08 18:19:56 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-05 00:58:06 +05:00
|
|
|
module.exports = Setlang;
|