Skip to content

Commit

Permalink
[Fix] fixed kick 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 b01abc5 commit 0ec3b63
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions commands/Admin/kick.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ module.exports = {
embeds: [embedMessage("RED", `❌ | Please mention a user to kick!`)],
});

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

const embed = {
author: {
Expand All @@ -36,7 +35,7 @@ module.exports = {
},
{
name: "Reason",
value: `${kickReason}`,
value: `\`${kickReason ? kickReason : "No Reason provided!"}\``,
},
],
timestamp: new Date(),
Expand All @@ -63,11 +62,14 @@ module.exports = {
});

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

try {
await interaction.guild.members.kick(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 kick ${user}, ${error.message}`),
],
Expand Down

0 comments on commit 0ec3b63

Please sign in to comment.