0
votes

I'm back on the grind of working with this discord bot, and at this point, I've gotten so attached to her that I decided to whip up a couple of companion bots for her that she can respond back and forth with in little conversations! The thing is, to allow her to talk with the other bots, I simply deleted this line of code...

if (message.author.bot) return;

...and it turns out, that had some repercussions I probably should've expected, and as soon as I brought up her rei!help command, it set off every single one of her other commands...

Are there any alternatives to the code above that I can use so that she only doesn't respond to her own messages? I've seen (message.userID === bot.userID) used, but for my bot, it just locks up and doesn't respond to anything if I copypaste that code in. It doesn't bring up an error message either...

Any help is appreciated, thanks!

EDIT: clairification for what's around the line of code here!

///constants and dependencies above here

//console log
bot.on('ready',() => {
   console.log('Up and running!!!');
});

//set 'playing' to
bot.on('ready', () => {
 bot.user.setActivity('hehe clairvoyance time')
});

//bot stuff
bot.on('message', message => {
  // heres the stuff so reibot doesnt go ham every time someone does rei!help
  if (message.author.bot) return;

///all commands below here
1

1 Answers

3
votes

You can check if the ID of the author is that of the client. That way, it'll ignore any messages sent by itself (and only itself).

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