-
Notifications
You must be signed in to change notification settings - Fork 0
/
unban.js
26 lines (23 loc) · 829 Bytes
/
unban.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const { SlashCommandBuilder, PermissionFlagsBits } = require('discord.js')
module.exports = {
data: new SlashCommandBuilder()
.setName('unban')
.setDescription('Unban a user from the server')
.addStringOption((option) => option
.setName('user_id')
.setDescription('The user ID you want to unban from the server')
.setRequired(true)
)
.setDefaultMemberPermissions(PermissionFlagsBits.UnbanMembers),
async execute(interaction) {
let user = interaction.options.getString('user_id')
let bans = await interaction.guild.bans.fetch()
let bannedUser = bans.find(ban => ban.user.id.toString() === user)
if (bannedUser) {
await interaction.guild.members.unban(bannedUser.user)
await interaction.reply(':white_check_mark: User unbanned')
} else {
await interaction.reply('User not found')
}
}
}