Is there a way to include various reactions at once?

I've been searching everywhere for solutions but I'm stuck on this issue.

Here's the scenario I'm dealing with:

  • I need my bot to execute a command that will send an embed to a specific channel accessible only by admins. Done.

  • Following that, the bot should automatically react to its own message with number emojis 1, 2, and 3. Issue.

  • I want the bot to not wait for a reaction from an admin. The embed should remain until an admin reacts to it, whether that happens in a minute or days later. However, if the bot is restarted, it stops waiting for the reaction. I have an event in place which triggers when someone reacts with a particular emoji, though it could use some enhancements but it does work:
bot.on("messageReactionAdd", (messageReaction, user) => {
    console.log(messageReaction);
    if(reaction.emoji.name === "\u0031\u20E3") {
        message.channel.send('one'); //Just a temporary test. More code will be added here eventually.
    }
    else if(reaction.emoji.name === "\u0032\u20E3") {
        message.channel.send('two');
    }
    else if(reaction.emoji.name === "\u0033\u20E3") {
        message.channel.send('three');
    }
});

The challenge I'm facing is that when running this piece of code:

let cmdEmbed = new discord.RichEmbed()
    .setTitle('**Command Menu Test**')
    .setDescription("Type commands")
    .setAuthor('InfernoBot', 'https://cdn.discordapp.com/avatars/533089334224617474/17ddec7cb178601d17964040ed8dc32d.png?size=2048')
    .setColor(0xD41519);
message.channel.sendEmbed(cmdEmbed).then(function (message) {
    message.react('\u0031\u20E3')
    message.react('\u0032\u20E3') //This part is not working
    message.react('\u0033\u20E3') //This part is not working
});

It only ever adds the reaction of the '1' emoji.

How can I make it so that the bot reacts with numbers 1, 2, and 3 as emojis, without having to wait for a reaction?

PS: I plan to implement code that will resend the same embed with the same reactions once the current embed has been reacted to, essentially resetting it.

EDIT: The bot doesn't always react with 1. Sometimes it only adds one reaction. It's inconsistent. .

Answer №1

After around half an hour of searching, I finally found the solution to the issue I was facing. Here is what worked for me:

The problematic part of my original code was causing the bot to crash and restart.

I made the following replacements in my code:

bot.on("messageReactionAdd", (reaction, user) => {
    if(user.toString() !== '<@533089334224617474>' /*InfernoBot ID*/) {
        console.log('User is not InfernoBot')
        if(reaction.emoji.name === "\u0031\u20E3") {
            // Updated code goes here
        }
    }
});

And I also updated the second chunk of code as follows:

let cmdEmbed = new discord.RichEmbed()
    .setTitle('**Command Menu Test**')
    .setDescription("Type commands")
    .setAuthor('InfernoBot', 'https://cdn.discordapp.com/avatars/533089334224617474/17ddec7cb178601d17964040ed8dc32d.png?size=2048')
    .setColor(0xD41519);
message.channel.sendEmbed(cmdEmbed).then(function (message) {
    message.react('\u0031\u20E3').then(() => message.react('\u0032\u20E3')).then(() => message.react('\u0033\u20E3'));
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting why Vue.js isn't updating the DOM with two-way binding

I'm currently utilizing Vue.js for implementing two-way binding. One issue I am facing is with an edit button that should convert a text field into an input field upon clicking. However, the DOM does not update immediately as expected. For instance: ...

Simulating TypeDI service behavior in Jest

My current setup includes Node with TypeScript, TypeDI and Jest. I've been working on creating services that have dependencies on each other. For example: @Service() export class MainService{ constructor(private secondService: SecondService){} public ...

Is it possible to load multiple angular applications within a master angular shell application?

I am searching for a method to integrate multiple Angular applications into a single shell Angular application. The concept involves having different teams develop separate Angular apps that can be loaded within a main shell app visible to end users. Thi ...

The internal cjs loader in node threw an error at line 1078

I'm encountering an error on Windows 10 when running the npm command: node:internal/modules/cjs/loader:1063 throw err; ^ Error: Cannot find module 'D:\mobile-version portfolio\ at Module._resolveFilename (node:internal/modules/cjs/load ...

Combine mongoose $sum aggregations

I am facing a query that looks like the following: {"$match": {$or: [{"to": system.mongoose.Types.ObjectId(userId)}, {"from": system.mongoose.Types.ObjectId(userId)}]}}, {"$sort": {"createDate": -1}}, { "$group": { ...

Managing user access and permissions using JavaScript on the front end

I find myself in a situation where I am working on developing a single page application: The majority of the operations rely on ajax requests. Depending on the user's login status (admin, regular user, visitor), different components need to be displ ...

D3 not distinguishing between bars with identical data even when a key function is implemented

When attempting to create a Bar chart with mouseover and mouseout events on the bars using scaleBand(), I encountered an issue. After reviewing the solution here, which explains how ordinal scale treats repeated values as the same, I added a key to the dat ...

Sequelize - The name 'xxx_idx' for the identifier is too lengthy while trying to establish a one-to-many relationship

I am working with 2 tables, physical-assessment-exercise and physical-assessment-lesson. In the file psysical-assessment-lesson.model.js: const Sequelize = require('sequelize'); const DataTypes = Sequelize.DataTypes; module.exports = function ( ...

The identical page content is displayed on each and every URL

Implementing a multi-step form in Next JS involves adding specific code within the app.js file. Here is an example of how it can be done: import React from "react"; import ReactDOM from "react-dom"; // Other necessary imports... // Add ...

Using Vue.js, send information from an Ajax request to a Laravel controller for processing

As someone new to development, I have a little confusion with handling data from a multi-step form in an AJAX request on my controller. While I've been able to successfully collect all form inputs at once, I'm struggling to use the data from $req ...

Using radio buttons to toggle the visibility of a div element within a WordPress website

I am currently working on creating a WordPress page using the custom page tool in the admin interface. My goal is to have 3 radio buttons, with 2 visible and 1 hidden. The hidden button should be automatically checked to display the correct div (although ...

Using jQuery combogrid to automatically target and populate input box upon row selection

I have implemented combogrid functionality from https://github.com/powderblue/jquery-combogrid to display suggestions while typing. $(".stresses").combogrid({ url: '/index/stresssearch', debug: true, colModel: [{'col ...

Maintain the visibility of the jQuery dropdown menu even when navigating to a different page within the

I am experiencing an issue with my dropdown menu. Whenever I click on a "dropdown link", it opens another page on my website, but the menu closes in the process. I want to ensure that the menu stays open and highlights the clicked "dropdown link" in bold. ...

Error encountered while using the Fetch API: SyntaxError - the JSON data contains an unexpected character at the beginning

I've been troubleshooting a contact form and there seems to be an error causing it to malfunction. It's strange because when I switch from Fetch to XMLHttpRequest, the code works fine. With Fetch, if I don't request a response, no errors ar ...

Having trouble with SCSS styles not being applied after refactoring to SCSS modules?

Currently, I am in the process of restructuring an application to ensure that component styles are separated from global styles using CSS modules. However, I have come across an issue where the styles are not being applied correctly. The original code sni ...

Empty jQuery $.ajax value after post

I'm encountering an issue where my code's post value appears to be empty. I have attempted to echo the key and value using a foreach loop, but it only shows "0 Array." This is what my code looks like: <script type="text/javascript"> $(doc ...

Leveraging NPM 'pre' commands

Utilizing NPM, we have the ability to implement pre scripts to function as pre hooks (in addition to post hooks). In my case, I am aiming to execute 'gulp default' prior to running my npm script in the following manner: "scripts":{ "prestart ...

Looking for search suggestion functionalities in an HTML input field

I am currently working on a website project and have a database filled with recipes to support it. The issue I am facing is related to the search feature on my webpage. At the top of the page, there is a textarea where users can input their search queries ...

Find the ID of the clicked table row using HTML and JavaScript

Currently, I am trying to implement this code snippet: <td align="center"> <div class="dropdown"> <button onclick="DropdownShow(this)" class="btn btn-default glyphicon glyphicon-picture"></button> <div id="@TableR ...

How can we eliminate the need for specifying the order of generic arguments in TypeScript?

In the development of my middleware engine, I have incorporated various generic arguments that are specific to the particular implementation in use. export type Middleware< Store = never, Args = unknown, Response = unknown > = ( context: { ...