-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New] Added unban command by user id and reason
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
const { SlashCommandBuilder } = require("@discordjs/builders"); | ||
const { Permissions } = require("discord.js"); | ||
const { embedMessage } = require("../../modules/embedSimple"); | ||
|
||
module.exports = { | ||
data: new SlashCommandBuilder() | ||
.setName("unban") | ||
.setDescription("unbans a user with id") | ||
.addStringOption((option) => | ||
option | ||
.setName("id") | ||
.setDescription("The ID of the user you want to unabn") | ||
.setRequired(true) | ||
) | ||
.addStringOption((option) => | ||
option.setName("reason").setDescription("ban reason").setRequired(true) | ||
), | ||
async execute(interaction, client) { | ||
const userID = interaction.options.getString("id"); | ||
const reason = interaction.options.getString("reason"); | ||
await interaction.deferReply(); | ||
|
||
const embed = { | ||
author: { | ||
name: `${interaction.user.username}`, | ||
icon_url: `${interaction.user.avatarURL()}`, | ||
}, | ||
color: "#9dcc37", | ||
title: `User unbanned successfully`, | ||
fields: [ | ||
{ | ||
name: "User ID:", | ||
value: `${userID}`, | ||
inline: true, | ||
}, | ||
{ | ||
name: "Reason", | ||
value: `${reason}`, | ||
}, | ||
], | ||
timestamp: new Date(), | ||
}; | ||
|
||
if (!interaction.member.permissions.has([Permissions.FLAGS.ADMINISTRATOR])) | ||
return await interaction.followUp({ | ||
embeds: [ | ||
embedMessage( | ||
"#9dcc37", | ||
`❌ | You do not have permission to unban members!` | ||
), | ||
], | ||
}); | ||
|
||
try { | ||
await interaction.guild.members.unban(userID, { reason }); | ||
await interaction.followUp({ embeds: [embed] }); | ||
} catch (error) { | ||
await interaction.followUp({ | ||
embeds: [ | ||
embedMessage( | ||
"#9dcc37", | ||
`Couldn't ban <@${userID}>, ${error.message}` | ||
), | ||
], | ||
}); | ||
console.log(error); | ||
} | ||
}, | ||
}; |