[Solved] How to add “reason” thing to ban command


Simply use member.ban('reason here'). Use an object if you need to delete previous messages and supply a reason, like so:

member.ban({days: 2, reason: 'bad'});

Now, just use this setup with the user’s reason. Use a variable for the reason as a sliced version of the arguments array, joined with spaces.

Edit: Showing context…

if (message.content.toLowerCase().startsWith('+ban')) { // changed to case insensitive command
  const member = message.mentions.members.first(); // keep in mind it isn't the best practice to use message.mentions to retrieve an argument
  if (!member) return message.channel.send('no member mentioned');
  let reason = args.slice(2).join(' '); // arguments should already be defined
  member.ban(reason)
  .then(message.channel.send('success'))
  .catch(err => {
    message.channel.send('something went wrong');
    console.error();
  });
}

2

solved How to add “reason” thing to ban command