Absence of reactions visible

I am eagerly awaiting responses to a message. The member begins typing, then the bot responds, and the user is expected to react to the bot's message. I attempted to execute this code, however, when it reached the console.log("OK"), nothing happened. (Apologies for the Hungarian code)

if (message.channel.id === "714071018733568031" && !message.author.bot && !message.content.startsWith("!jovahagy")) { // ID
    message.author.send("Thank you for responding! We will confirm shortly! Please wait.")
    const Discord = require('discord.js');
    const embedMsg = new Discord.MessageEmbed()
    embedMsg.setColor('ee00ff')
    embedMsg.setTitle('Join Request')
    embedMsg.setAuthor('KraftBOT', 'https://s1.bozaiakos.hu/tkomprofile.jpg', 'https://magentakraft.hu')
    embedMsg.setDescription('Someone wants to join the server and has responded to the question!')
    embedMsg.addField('Applicant', `${message.author}`)
    embedMsg.addField('Message', `${message.content}`)
    embedMsg.addField('\u200B', '\u200B')
    embedMsg.addField('Approval', `!jovahagy ${message.author}`)
    embedMsg.addField('Rejection', `!elutasit ${message.author}`)
    embedMsg.setFooter('Bozai Ákos - Professional servers, bots, websites.', 'https://bozaiakos.hu/images/logokor.png');
    message.delete();
    client.channels.cache.get("714071028925464586").send({embed: embedMsg}) // ID
    .then(nMessage => {nMessage.react('✅').then(r => {
      nMessage.react('❎');
});

// First argument is a filter function
nMessage.awaitReactions((reaction, user) => user.id == message.author.id && (reaction.emoji.name == '✅' || reaction.emoji.name == '❎'),
      { max: 1 }).then(collected => {
              if (collected.first().emoji.name == '✅') {
                const accepted = message.author;
                if (!accepted.roles.cache.some(r => r.name === "Verification in progress")) {
                  nMessage.delete();
              } else {
                console.log("OK");
              try {
                var role = message.guild.roles.cache.find(role => role.name === "Member");
                accepted.roles.add(role);
                var role = message.guild.roles.cache.find(role => role.name === "Verification in progress");
                accepted.roles.remove(role);
              } catch (error) {return;}
              accepted.send(`${message.author} has approved you on the MagentaKraft server. You can now chat.`)
              const Discord = require('discord.js');
              const embedMsg = new Discord.MessageEmbed()
              embedMsg.setColor('00ff11')
              embedMsg.setTitle('Join Approved')
              embedMsg.setAuthor('KraftBOT', 'https://s1.bozaiakos.hu/tkomprofile.jpg', 'https://magentakraft.hu')
              embedMsg.setDescription('A member's joining request has been accepted.')
              embedMsg.addField('Approved Member', `${accepted}`,true)
              embedMsg.addField('Approved by', `${message.author}`,true)
              embedMsg.addField('Applicant Response', `${message.content}`)
              embedMsg.setFooter('Bozai Ákos - Professional servers, bots, websites.', 'https://bozaiakos.hu/images/logokor.png');
              client.channels.cache.get("714071038962696262").send({embed: embedMsg});
              nMessage.delete();
              }

              }
              else if (collected.first().emoji.name == '❎') {
                const accepted = message.author;
                if (!accepted.roles.cache.some(r => r.name === "Verification in progress")) {
                  nMessage.delete();
              } else {

              accepted.send(`${message.author} has rejected you on the MagentaKraft server. Please contact us for details! Common reasons for rejection include: \n- Incorrect name (e.g. starts with a symbol)
              \n- Non-serious application text (spelling errors, off-topic, etc.)`)
              const Discord = require('discord.js');
              const embedMsg = new Discord.MessageEmbed()
              embedMsg.setColor('ff0000')
              embedMsg.setTitle('Join Rejected')
              embedMsg.setAuthor('KraftBOT', 'https://s1.bozaiakos.hu/tkomprofile.jpg', 'https://magentakraft.hu')
              embedMsg.setDescription('A member's joining request has been rejected.')
              embedMsg.addField('Rejected Member', `${accepted}`,true)
              embedMsg.addField('Rejected by', `${message.author}`,true)
              embedMsg.addField('Applicant Response', `${message.content}`)
              embedMsg.setFooter('Bozai Ákos - Professional servers, bots, websites.', 'https://bozaiakos.hu/images/logokor.png');
              client.channels.cache.get("714071039004508220").send({embed: embedMsg});
              try {
                accepted.kick();
              } catch (error) {return;}
              nMessage.delete();
              }
      }
    })

What steps should I take next? I have reviewed everything, including my roles, but there was no action when I reacted with a check mark.

Answer №1

By arranging it this way, the bot will only respond after the checkmark if there is a role named Verification in progress. You can try further debugging, but it's challenging when the code is repetitive and buggy (possibly due to reusing variable names).

Here is a clearer and cleaner version, although some parts of the code can still be improved. Make sure to place it in an async function since it uses async operations:

// It's unclear why you had it inside the if statement initially
const Discord = require('discord.js');

if (message.channel.id === "714071018733568031" && !message.author.bot && !message.content.startsWith("!approve")) { // Channel ID
    const author = message.author;
    author.send("Thank you for responding! We will confirm shortly! Please wait.");
    const embedMsg = new Discord.MessageEmbed()
        .setColor('ee00ff')
        .setTitle('Membership Request')
        .setAuthor('KraftBOT', 'https://s1.bozaiakos.hu/tkomprofile.jpg', 'https://magentakraft.hu')
        .setDescription('Someone wants to join the server and has responded to the question!')
        .addField('Applicant', `${author}`)
        .addField('Message', `${message.content}`)
        .addField('\u200B', '\u200B')
        .addField('Approval', `!approve ${author}`)
        .addField('Rejection', `!reject ${author}`)
        .setFooter('Bozai Ákos - Professional servers, bots, websites.', 'https://bozaiakos.hu/images/logokor.png');

    message.delete();

    const cachedChannel = client.channels.cache.get("714071028925464586");
    const nMessage = await cachedChannel.send(embedMsg); // Channel ID
    await nMessage.react('✅');
    await nMessage.react('❎');

    const filter = (reaction, user) => user.id == author.id && (reaction.emoji.name == '✅' || reaction.emoji.name == '❎');

    // The first argument is a filter function
    nMessage.awaitReactions(filter, { max: 1 })
        .then(collected => {
            const emojiName = collected.first().emoji.name;
            if (emojiName == '✅') {
                if (!author.roles.cache.find(r => r.name === "Verification in progress")) return nMessage.delete();

                console.log("OK");
                try {
                    const roleToAdd = message.guild.roles.cache.find(role => role.name === "Member");
                    const roleToRemove = message.guild.roles.cache.find(role => role.name === "Verification in progress");

                    // Check if the roles exist?
                    author.roles.add(roleToAdd);
                    author.roles.remove(roleToRemove);
                } catch (error) {
                    // Consider using console.error instead
                    return;
                }

                author.send(`${author} has approved you on the MagentaKraft server. You can now start chatting.`);

                const nextEmbed = new Discord.MessageEmbed()
                    .setColor('00ff11')
                    .setTitle('Membership Approved')
                    .setAuthor('KraftBOT', 'https://s1.bozaiakos.hu/tkomprofile.jpg', 'https://magentakraft.hu')
                    .setDescription('A member's request has been approved.')
                    .addField('Approved Member', `${author}`, true)
                    .addField('Approved By', `${author}`, true)
                    .addField('Applicant Response', `${message.content}`)
                    .setFooter('Bozai Ákos - Professional servers, bots, websites.', 'https://bozaiakos.hu/images/logokor.png');

                cachedChannel.send(nextEmbed);
                nMessage.delete();
                return;
            }

            if (!author.roles.cache.find(r => r.name === "Verification in progress")) return nMessage.delete();
            author.send(`${author} has rejected you on the MagentaKraft server. For more details, please contact one of our contacts! Common reasons for rejection include: \n- Incorrect name (e.g., starting with a symbol)
              \n- Unserious application text (spelling mistakes, deviation from the topic, etc.)`);

            const nextEmbed = new Discord.MessageEmbed()
                .setColor('ff0000')
                .setTitle('Membership Rejected')
                .setAuthor('KraftBOT', 'https://s1.bozaiakos.hu/tkomprofile.jpg', 'https://magentakraft.hu')
                .setDescription('A member's request has been rejected.')
                .addField('Rejected Member', `${author}`, true)
                .addField('Rejected By', `${message.author}`, true)
                .addField('Applicant Response', `${message.content}`)
                .setFooter('Bozai Ákos - Professional servers, bots, websites.', 'https://bozaiakos.hu/images/logokor.png');

            cachedChannel.send(nextEmbed);

            try {
                author.kick();
            } catch (error) { return; }

            nMessage.delete();
        })
}

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

Unable to get ng-submit function to work properly within the Laravel PHP framework

Hello everyone, I have an inquiry regarding Laravel/AngularJS. In my project, there is a form where users can post questions. However, when I click the submit button, no requests are sent (as per inspection in Google Chrome). Interestingly, the Log in int ...

Leveraging the Spread Operator in Redux mapDispatchToProps with SweetAlert2

When I add the swal action creators to the mapDispatchToProps function like this: function mapDispatchToProps(dispatch) { return { getAnimal: (_id) => dispatch(getAnimal(_id)), ...swal } } The issue aris ...

Determine the total count of files in queue with Uploadify prior to initiating the upload process

When I specify auto: false in the uploadify settings, the upload process will only start when the submit button is clicked. Once the onQueueComplete event is triggered, the form will be submitted. However, if no files are selected, the onQueueComplete even ...

Is there a specific minimum height that should be set for the equalHeight function to apply?

Despite trying everything, I can't seem to achieve the dreadful layout my designer has given me without using JavaScript! The issue lies with the positioning of the div #backgr-box, which needs to be absolutely positioned behind the #contenuto ( ...

Utilizing Axios to filter response.data in an API request

Looking to retrieve the latest 8 products based on their date? Take a look at the code snippet below: const newestProducts= []; axios.get("http://localhost:3003/products").then(response => { let products = response.data.sort(fu ...

How can I trigger a method after the user has finished selecting items in a v-autocomplete with multiple selection using Vuetify?

After multiple selections are made in a v-autocomplete, I need to trigger a method. However, the @input and @change events fire after each selection, not after the full batch of selections. Is there an event that triggers when the dropdown menu closes? Al ...

What is the best way to trigger a modal on Bootstrap using a JavaScript/jQuery function?

I encountered an issue while attempting to call a bootstrap modal using a simple button or link, which may be due to a conflict with my select2 plugin (although I am uncertain). I tried appending the button to the select2 dropdown but it doesn't seem ...

Automatically populate the article number field once the article name has been entered

I am currently working on a HTML <form> using PHP. Within this form, there are three <input> fields. The goal is to have the second <input> field automatically populate once the first one is filled out. This will involve triggering an HTT ...

Accessing PageController through XmlHttpRequest is not allowed in Shopware 6

I'm encountering an issue when attempting to send a request to my customized StorefrontController on the most recent version of Shopware 6.2.2. The error message I'm receiving is: PageController can't be requested via XmlHttpRequest. I&apos ...

Decide on the javascript/jquery libraries you want to include

My app is experiencing slow loading times on the home screen and students using it from school district computers are running into ERR_CONNECTION_RESET errors due to strict firewalls. The excessive loading of javascript and jquery libraries in the head of ...

Dealing with the hAxis number/string dilemma in Google Charts (Working with Jquery ajax JSON data)

My Objective I am attempting to display data from a MySQL database in a "ComboChart" using Google Charts. To achieve this, I followed a tutorial, made some modifications, and ended up with the code provided at the bottom of this post. Current Behavior T ...

Some sections of the HTML form are failing to load

I'm currently following a tutorial and applying the concepts to a Rails project I had previously started. Here's my main.js: 'use strict'; angular.module('outpostApp').config(function ($stateProvider) { $stateProvider.sta ...

Error: Firebase has encountered a network AuthError, which could be due to a timeout, interrupted connection, or an unreachable host. Please try again later. (auth/network-request-failed

I have set up my Angular app to utilize Firebase's emulators by following the instructions provided in this helpful guide. In my app.module.ts, I made the necessary configurations as shown below: import { USE_EMULATOR as USE_AUTH_EMULATOR } from &apos ...

I am looking to halt the AJAX requests within an asynchronous function after reaching a limit of 10 requests

I've been working on an async function that sends AJAX requests based on the previous response. The function is functioning properly, but it's sending multiple requests in quick succession. I need to implement a 5-second interval between each req ...

Exclude the footer from the index.html file by configuring it in the docusaurus.config.js file

From what I understand, the docusuarus.config.js file is responsible for translating specified information into HTML to construct your website. This translated information is then directed to the 'index.html' file. However, I am encountering an ...

How can I use JavaScript to update the content inside HTML tags with a specific string?

I have a situation where I need to replace a string in two different ways Input: Parameters-->string, AnnotationName, input Case 1: And I should input <i>Annotaion</i> as <b>input</b> Output : { displayData: `And I should inp ...

problem with saving session data

I am attempting to access data from another page using session storage. On my initial page, named home.html function go_to_faq(qnum){ window.open('FAQ.html', '_blank'); sessionStorage.setItem('key2', qnum); } <a s ...

How can I use JavaScript to disable a table row and then save the selected option in a MySQL database?

I have a PHP snippet that dynamically displays table rows. Each row contains a radio button with "Yes" and "No" options. I have implemented a JS function where, upon choosing an option, a pop-up box is displayed. If the user selects the "Yes" option in t ...

UI-Router is malfunctioning, causing ui-sref to fail in generating the URL

I'm currently working on a project that involves Angular, Express, and UI-router for managing routes. While I've properly configured my $states and included the necessary Angular and UI-router libraries in my HTML file, I am facing an issue wher ...

How to Retrieve the Absolute Index of the Parent Column Using jQuery Datatables

I recently developed a custom column filtering plugin for datatables, but I've encountered a minor issue. Within each column footer, I have added text inputs, and now I am trying to capture their indexes on keyup event to use them for filtering. In ...