every time I do !ban [user]
, the bot crashes and I don’t know why, would be wonderful if some one could help
my code:
if (message.content.startsWith("!ban")) {
const author = message.author
const messageContent = message.content.split(' ').slice(1).join(' ');
if (!messageContent) {
return message.reply("please tell me who you would like me to ban!")
} else {
if (messageContent = author) {
return message.reply("You cant ban yourself silly!")
}
}
}
2
Answers
Without providing the error message, it is difficult to determine what is going on. However, you are using the equality operators incorrectly.
Currently, on the line
if (messageContent = author) {
, you have defined a variable inside of an if-statement.The correct way of doing so would as as follows:
Full example:
An enhacement of the code: