JaBa/commands/Administration/setlang.js

33 lines
881 B
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js");
class Setlang extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "setlang",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["setl"],
2021-12-26 19:29:37 +05:00
memberPermissions: ["MANAGE_GUILD"],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 1000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-10 21:39:54 +05:00
const language = this.client.languages.find((l) => l.name === args[0] || l.aliases.includes(args[0]));
2021-12-11 01:11:50 +05:00
if (!args[0] || !language) return message.error("administration/setlang:MISSING_LANG", { list: this.client.languages.map((l) => `\`${l.name}\``).join(", ") });
2021-12-10 21:39:54 +05:00
data.guild.language = language.name;
await data.guild.save();
2021-12-26 19:29:37 +05:00
return message.sendT("administration/setlang:SUCCESS", {
lang: language.nativeName
});
2021-12-10 21:39:54 +05:00
}
};
module.exports = Setlang;