JaBa/commands/Moderation/unban.js

56 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-07-03 21:13:08 +05:00
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Unban extends BaseCommand {
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("unban")
.setDescription(client.translate("moderation/unban:DESCRIPTION"))
.setDescriptionLocalizations({
2023-07-05 00:58:06 +05:00
uk: client.translate("moderation/unban:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/unban:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
2023-07-03 21:13:08 +05:00
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
2023-07-05 00:58:06 +05:00
.addStringOption(option =>
option
.setName("user_id")
.setDescription(client.translate("common:USER_ID"))
.setDescriptionLocalizations({
uk: client.translate("common:USER_ID", null, "uk-UA"),
ru: client.translate("common:USER_ID", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
2023-11-05 16:03:23 +05:00
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
2022-08-09 23:48:33 +05:00
* @param {Object} data
*/
async execute(client, interaction) {
const id = interaction.options.getString("user_id"),
banned = await interaction.guild.bans.fetch();
if (!banned.find(u => u.user.id === id)) return interaction.error("moderation/unban:NOT_BANNED", { id });
await interaction.guild.bans.remove(id);
interaction.success("moderation/unban:UNBANNED", {
id,
});
}
}
2023-07-05 00:58:06 +05:00
module.exports = Unban;