Skip to content

Commit

Permalink
[Fix] fixed ban command crashing if no reason was provided!
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Nov 25, 2021
1 parent 0ec3b63 commit 7f8bcb4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions commands/Admin/ban.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module.exports = {
embeds: [embedMessage("RED", `❌ | Please mention a user to ban`)],
});

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

const embed = {
author: {
name: `${message.member.user.username}`,
Expand All @@ -35,7 +35,7 @@ module.exports = {
},
{
name: "Reason",
value: `${banReason}`,
value: `\`${banReason ? banReason : "No Reason provided!"}\``,
},
],
timestamp: new Date(),
Expand All @@ -62,11 +62,13 @@ module.exports = {
});

try {
await message.guild.members.ban(user, { banReason });
await message.channel.send({ embeds: [embed] });
await message.guild.members.ban(user, {
reason: banReason ? banReason : "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", `❌ | Couldn't ban ${user}, ${error.message}`),
],
Expand Down Expand Up @@ -121,10 +123,10 @@ module.exports = {

try {
await interaction.guild.members.ban(user, { 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", `Couldn't ban ${user}, ${error.message}`)],
});
console.log(error);
Expand Down

0 comments on commit 7f8bcb4

Please sign in to comment.