0
message.channel.bulkDelete(args[0]+1)
.then(messages => message.channel.send(`${emojiyes} Deleted **${messages.size}** messages!`) | console.log(`Deleted ${messages.size} messages!`))

This causes deleting for example 21 messages, not 2 (_clear 2 deletes 21 messages, not 3). Can someone help me?

reed3324
  • 23
  • 2

1 Answers1

1

args[0] is a string and when combing that with one you are getting "2"+1 which results in 21. If you convert the string to a number first, it will calculate correctly. By using the parseInt() function we can convert the string into a number.

message.channel.bulkDelete(parseInt(args[0])+1)
.then(messages => message.channel.send(`${emojiyes} Deleted **${messages.size}** messages!`) | console.log(`Deleted ${messages.size} messages!`))
Levi_OP
  • 945
  • 1
  • 9
  • 22
  • No problem! If my answer was correct you could vote for it by hitting the up arrow and mark it as the answer by hitting the checkmark. – Levi_OP Feb 22 '21 at 18:27
  • I can't vote up, because I don't have 15 reputation points, sorry :( – reed3324 Feb 22 '21 at 18:31
  • That's fine! you should still be able to hit the checkmark (✓) to mark it as the answer! – Levi_OP Feb 22 '21 at 18:33