Skip to content

Commit

Permalink
[Fix] fixed unban command crashing if a reason was not provided!
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Nov 25, 2021
1 parent 756c16e commit 34b3fa9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions commands/Admin/unban.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ module.exports = {
],
});

const noargs0 = args.shift();
const unbanReason = args.join(" ");
const unbanReason = args.slice(1).join(" ");

const embed = {
author: {
Expand All @@ -40,7 +39,7 @@ module.exports = {
},
{
name: "Reason",
value: `${unbanReason}`,
value: `\`${unbanReason ? unbanReason : "No Reason Provided"}\``,
},
],
timestamp: new Date(),
Expand All @@ -57,11 +56,13 @@ module.exports = {
});

try {
await message.guild.members.unban(userID, { unbanReason });
await message.channel.send({ embeds: [embed] });
await message.guild.members.unban(userID, {
reason: unbanReason || "No Reason",
});
return await message.channel.send({ embeds: [embed] });
} catch (error) {
client.logger(error.message, "error");
await message.channel.send({
return await message.channel.send({
embeds: [
embedMessage(
"RED",
Expand All @@ -84,9 +85,9 @@ module.exports = {
option.setName("reason").setDescription("ban reason").setRequired(true)
),
async execute(interaction, client) {
await interaction.deferReply();
const userID = interaction.options.getString("id");
const reason = interaction.options.getString("reason");
await interaction.deferReply();

const embed = {
author: {
Expand Down Expand Up @@ -121,10 +122,10 @@ module.exports = {

try {
await interaction.guild.members.unban(userID, { reason });
await interaction.followUp({ embeds: [embed] });
return await interaction.followUp({ embeds: [embed] });
} catch (error) {
client.logger(error.message, "error");
await interaction.followUp({
return await interaction.followUp({
embeds: [
embedMessage(
"RED",
Expand Down

0 comments on commit 34b3fa9

Please sign in to comment.