Message Reactions

I am making a discord bot using js. I have followed code on Discord.js guide. I am attempting to create a reaction bot that gives you a role or send you a message when you react to a certain message. Here is my code so far:

const Discord = require(‘discord.js’);
const client = new Discord.Client();

client.once(‘ready’, () => {

client.on(‘message’, message => {

if (message.content === ‘!react’) {


Hey @TMD,

All you need to do is add a reactionAdd event!

Add this to your code

client.on("messageReactionAdd", async (reaction, user) => {
  if ( return;
  var message = reaction.message;

The first thing it does it prevent bots from getting roles and declares message as reaction.message;

then you need to check what emoji is reacted so use this:

if (reaction.emoji == "🔒") { // replace the lock with any emoji


then you want to give the author of the message the role by using this:"role-id-goes-here", "Reaction Roles")

replace the "role-id-goes-here with the role id you want to give and Reaction Roles for the reason.

To send a message user"message content")

Then your code should look like this:

client.on("messageReactionAdd", async (reaction, user) => {
  if ( return;
  var message = reaction.message;
    if (reaction.emoji == "🔒") {
      message.member.addRole("role-id", "reason")"You reacted with 🔒 and got the [role-name] role!")

Hope this helps!

Thank you @MrDiamond64 I added this to the command code! My bot doesn’t seem to send the command to a channel in my server. Is this a problem on my end?

Oh! i thought you meant to DM the user! well you can also do that! All you have to do is use this:

client.channels.find(cn => == "").send("Message Content")

Thank you! @MrDiamond64

The command still isn’t sending in the channel. It doesn’t even acknowledge that a command was typed. Is there something wrong with the code to not allow the bot to see the command input?

Have you replaced the lock wit the emoji you want? is there any logs you can show?

This is all it shows.

But then when I go to the link it says the web is down
And when I ping the bot and the bot that used to work 100%, it just says the prefix instead of what it is coded to say.
And on top of that the code for the presence is no longer working.

If you try your changes right after you make them, they might have not gone through yet (because of establishing of websockets, etc)

is the reactionAdd handler in your main bot file?

@MrDiamond64 Main bot file? I have sub files like for commands, what do you mean by a main bot file?

@youngchief_btw I update the bot every time so the commands can be used instantly.

Your index.js or where the message handler is

@MrDiamond64 like in my package.json folder?
These are my folders.Screenshot 2020-04-02 at 11.16.04 PM

The file where your ready event is. the place where it loads commands

it loads commands in everything, or it used to.

So what exactly do you mean by the file where the “ready” event is.

the file where your bot login to discord

i just invite it, what you mean?

where is your client.login() located at?

i dont have one :eyes:

I don’t have one for my other bot that someone made for me. And it works fine

How does your bot work then?