Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if the author of a message was a Discord bot?

The title explains my question. This question might sound stupid, but how do I detect if the author of a message was a Discord bot?

Thanks.

like image 943
Brandon Avatar asked Apr 05 '18 02:04

Brandon


People also ask

How do you know if someone on Discord is a bot?

The most common way to tell if an account is fake is to check out the profile. The most rudimentary bots lack a photo, a link, or any bio. More sophisticated ones might use a photo stolen from the web, or an automatically generated account name. Using human language is still incredibly hard for machines.

Can a Discord bot DM you?

Bots Be Able To DM You – Discord.

What does writer bot do in Discord?

Writer-Bot is a discord bot for writing-based servers. It has many features, such as writing sprints, word count goals, xp/levels, prompts and random generators. ! ask : Asks you a random question about your character or your world, to get the creative juices flowing.


2 Answers

If you want to check if a message author is a bot account you can easily do:

if(message.author.bot) return;

This will return if a user is a bot. If it isn't will keep going.
If you want to check if the message author is the logged in bot you can do:

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

This is gonna return if the message author is the bot, it will keep going if its another bot.

like image 73
André Avatar answered Sep 28 '22 09:09

André


for those looking for an answer on how to check if it was your bot who added a reaction. In that case you can check like it like:

client.on('messageReactionAdd', (messageReaction, user) => {
  if (messageReaction.me === false) {
    // This reaction was not added by the bot
  }
});
like image 45
Menno Guldemond Avatar answered Sep 28 '22 11:09

Menno Guldemond