JaBa/commands/Administration/setlang.js

64 lines
1.8 KiB
JavaScript
Raw Normal View History

2023-07-03 21:13:08 +05:00
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
2022-08-08 18:19:56 +05:00
const BaseCommand = require("../../base/BaseCommand");
class Setlang extends BaseCommand {
/**
*
* @param {import("../../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("setlang")
.setDescription(client.translate("administration/setlang:DESCRIPTION"))
.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"),
})
.setDMPermission(false)
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
aliases: [],
dirname: __dirname,
ownerOnly: false,
2022-08-08 18:19:56 +05:00
});
}
/**
*
* @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
2022-08-08 18:19:56 +05:00
*/
async execute(client, interaction, data) {
const lang = interaction.options.getString("language"),
language = client.languages.find(l => l.name === lang);
2022-08-08 18:19:56 +05:00
data.guildData.language = language.name;
2022-08-08 18:19:56 +05:00
await data.guildData.save();
return interaction.success("administration/setlang:SUCCESS", {
lang: language.nativeName,
2022-08-08 18:19:56 +05:00
});
}
}
2023-07-05 00:58:06 +05:00
module.exports = Setlang;