2022-08-06 20:47:47 +05:00
|
|
|
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
|
|
|
const BaseCommand = require("../../base/BaseCommand");
|
|
|
|
|
|
|
|
class Unban extends BaseCommand {
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {import("../../base/JaBa")} client
|
|
|
|
*/
|
|
|
|
constructor(client) {
|
|
|
|
super({
|
|
|
|
command: new SlashCommandBuilder()
|
|
|
|
.setName("unban")
|
|
|
|
.setDescription(client.translate("moderation/unban:DESCRIPTION"))
|
2022-10-13 00:05:36 +05:00
|
|
|
.setDMPermission(false)
|
2022-08-06 20:47:47 +05:00
|
|
|
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
|
|
|
|
.addStringOption(option => option.setName("user_id")
|
2022-11-09 21:33:45 +05:00
|
|
|
.setDescription(client.translate("common:USER_ID"))
|
2022-08-06 20:47:47 +05:00
|
|
|
.setRequired(true)),
|
|
|
|
aliases: [],
|
|
|
|
dirname: __dirname,
|
2022-12-15 21:02:38 +05:00
|
|
|
ownerOnly: false,
|
2022-08-06 20:47:47 +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-06 20:47:47 +05:00
|
|
|
*/
|
|
|
|
async execute(client, interaction) {
|
2023-01-09 01:39:13 +05:00
|
|
|
const id = interaction.options.getString("user_id"),
|
|
|
|
banned = await interaction.guild.bans.fetch();
|
|
|
|
|
2022-08-06 20:47:47 +05:00
|
|
|
if (!banned.find(u => u.user.id === id)) return interaction.error("moderation/unban:NOT_BANNED", { id });
|
|
|
|
|
2023-01-09 01:39:13 +05:00
|
|
|
await interaction.guild.bans.remove(id);
|
2022-08-06 20:47:47 +05:00
|
|
|
|
|
|
|
interaction.success("moderation/unban:UNBANNED", {
|
2022-12-15 21:02:38 +05:00
|
|
|
id,
|
2022-08-06 20:47:47 +05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Unban;
|