JaBa/commands/Administration/setlang.js
Jonny_Bro (Nikita) 4200ab3cde
v4.1.14 (#12)
Co-authored-by: Salosos <rabistov1834@gmail.com>
2022-11-09 21:33:45 +05:00

54 lines
No EOL
1.4 KiB
JavaScript

const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
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"))
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option => option.setName("language")
.setDescription(client.translate("common:LANGUAGE"))
.setRequired(true)
.addChoices(
{ name: "Русский", value: "ru-RU" },
{ name: "Українська", value: "uk-UA" }
)),
aliases: [],
dirname: __dirname,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const lang = interaction.options.getString("language");
const language = client.languages.find(l => l.name === lang);
data.guildData.language = language.name;
await data.guildData.save();
return interaction.success("administration/setlang:SUCCESS", {
lang: language.nativeName
});
}
}
module.exports = Setlang;