2022-08-08 18:19:56 +05:00
|
|
|
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"))
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-11-09 21:33:45 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
2022-08-08 18:19:56 +05:00
|
|
|
.addStringOption(option => option.setName("language")
|
|
|
|
.setDescription(client.translate("common:LANGUAGE"))
|
|
|
|
.setRequired(true)
|
|
|
|
.addChoices(
|
|
|
|
{ name: "Русский", value: "ru-RU" },
|
2022-12-15 21:02:38 +05:00
|
|
|
{ name: "Українська", value: "uk-UA" },
|
2022-08-08 18:19:56 +05:00
|
|
|
)),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
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) {
|
2023-01-09 01:39:13 +05:00
|
|
|
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;
|
|
|
|
await data.guildData.save();
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Setlang;
|