Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Discord bot deletes every message

Is there any way that I can stop my Discord bot from deleting all messages? I only want to delete messages that include banned words.

client.on('messageCreate', async message => {
  if (message.author.bot || !message.guildId) 
    return;

  if (message.content.includes(badWords))
    await message.reply("Not cool buddy you getting a timeout")
  message.delete()
  return;
})

Can anyone solve this because I couldn’t find anything? I asked some people too but I couldn’t understand what they mean.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It looks like a typo. You don’t have curly braces around the whole block you want to execute when that if statement is true:

client.on('messageCreate', async message => {
  if (message.author.bot || !message.guildId) 
    return;

  if (message.content.includes(badWords)) {
    await message.reply("Not cool buddy you getting a timeout")
    message.delete()
    return;
  }
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading