discord.js bot replies to itself

discord bot that responds to messages
discord bot respond to mention js
discord bot multiple responses
discord bot reply to user
discord.js if message contains
discord.js tag user
discord.js kick command
discord js webhook

I am currently coding my first discord bot, it can already play YouTube music.

if (message.content.includes("Good Job") || 
    message.content.includes("good job")) {
    message.channel.sendMessage("Good Job everyone :smirk:");
}

As you see, if someone types "good job" (this is just an example) then the bot will reply with "good job everyone :smirk:), but then the spam will begin: the bot reads his own message and replies to it.

How can I prevent the bot from answering itself?


Use this in the on message event:

if (message.author.bot) return;

for more info: https://anidiotsguide.gitbooks.io/discord-js-bot-guide/coding-guides/a-basic-command-handler.html

Why is my discord.js bot replying to itself, even when I put in a check , I have a bot that reacts and replies to messages containing certain keywords or but it's currently possible for users to make the bot reply to itself a few times. If you use Discord.js, try putting this at the very beginning of your ready event:. discord.js bot replies to itself. 2. How to make a Discord Bot wait for a specific user to send a message with JDA? 0. detect words inside embed fields. 2.


The reason why your bot replies to yourself is because where you put:

if (message.content.includes("Good Job") || 
    message.content.includes("good job"))

It is basically checking the chat if a piece of text includes the words "Good Job" or "good job". As your bot sends:

message.channel.sendMessage("Good Job everyone :smirk:");

as an answer, it creates a loop because that message includes the words "Good Job", basically running the code again and again and again.

Of course, the easiest way of fixing this is for you to change the answer it gives to not include the words Good Job, but there is better solution to make sure it doesn't happen for all of the commands you might make.

As @Jörmungandr said, under the message event include:

if (message.author.bot) return;

to make sure it doesn't happen. It essentially checks if the author of the message is a bot and if it is, it ignores it.

discord.js

How do I make my javascript discord bot ignore its own messages , This is, specifically, an event in discord.js but it's similar to how other APIs handle events. This event You might have noticed that a lot of bots respond to commands that have a prefix. This might be an This includes this bot, itself. And now� Discord.js bot manual reply by creator PM. Is it possible? Hot Network Questions Baking bread without yeast How do I wire a modern 240V 3 prong range to a 250V 50A 3


// In message event
if(message.author.id === client.user.id) return;

// I would recommend a variable like this for splits on words
// const args = message.content.trim().split(/\s+/g); 
// You could also .slice() off a prefix if you have one

if(/good job/i.test(message.content)) {
  message.channel.send('Good job everyone :smirk:'); // sendMessage is deprecated, use send instead
}

Your First Bot, Or maybe someone uses a command incorrectly, the bot might still It essentially just works itself through the structure of the mention bit by bit: if (! user) { return message.reply('Please use a proper mention if you want to� Yes, I use discord.js, and that solution worked. Thanks! Appreciate the help. One last thing. Do you know of any way to limit the number of responses it can send per message? e.g. currently if a user sends a message containing both a command and a keyword, the bot sends its keyword reply and responds to the command.


You can simply just check if the user sending the message is a bot. For example:

if (!msg.author.bot) {
    <Your code to execute if the user is not a bot.>
} 

Hope this was helpful, thank you!

Parsing mention arguments, Pretty simple idea of allowing bots to create messages like the client-side bot I' m currently in the process of creating a bot myself and this feature would be I would like to have a way to immediately and privately respond to the user in the� Most common way is to create a list with possible responses and let the bot randomly pick one. In NodeJs it would be something like this: var options = ["Hello", "Hi


Allow bots to create client-side bot messages like Clyde – Discord, It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend. The Perfect Lil' Bot. This bot example is the combined work of members of the Discord.js and Idiot Guide's community. It attempts to provide a "complete" starter example of a simple, one-file bot, with comments and information to properly understand each part and how it works.


discord.js, In this tutorial, you will create a Discord music bot using Discord.js which will to go online, we can start reading chat messages and responding to them. Note: This is a recursive function which means that it calls itself over and over again. Thank you, have a great day and stay tuned for more Discord.JS V12 tutorials! Loading Autoplay When autoplay is enabled, a suggested video will automatically play next.


How to create a music bot using Discord.js, SKIP command. js) 24/7 Commands Hey, I'm developing a bot with Discord. server "!usercount - Bot will respond with how many users are in the server ", discord. Discord is a playful and fun brand that doesn't take itself too seriously. Good afternoon Everyone, I've recently delved into bot creation for discord, got node.js setup and have a simple bot that i am adding features to and learning as I go (my main background is in game dev and C# development).