bot keeps repeating


April 2019


285 time


This discord bot keeps repeating what it just said concatenating two strings! Please help!

const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = "*";

client.on('message', (message) => {
    if (message.content == prefix + 'test') {"```User Bot is a way to get more users in your discord server. When you first invite the bot, it will create a channel called #invites. You can put your message in #invites by doing the command *message <message>. Doing this command will make the bot broadcast your message and your invite link so all people with the bot in there #invites channel will get the message.```");
    } else if (message.content == prefix + 'setup') {"```To setup User Bot, you must join the user bot discord listed here., then in #bots type your message!");
    } else if ( == 'UserBot' && == 'bots') {


function channel(message) {"***A server! " + message.content + "!***")

2 answers


As you have found out, the message event checks every single message inputted into the bot's guilds. To avoid it picking up the bot's messages, you can use

    if ( return;

or something along those lines. :)


I found an answer, it was triggering every time the bot spoke cause the conditions were and are the same.