Developed a verification process using Discord.JS, however, I'm not receiving any feedback when trying to configure the command

As I embark on creating my debut Discord bot to enhance my coding skills, I have encountered numerous hurdles along the way. While most of these challenges were overcome by me independently, this particular issue has left me stumped.

The objective of the code is to trigger a command that prompts the bot to set up verification in a designated channel. However, upon issuing the command, the bot remains unresponsive with no errors displayed in the command prompt.

In an attempt to pinpoint the problem area, I inserted the line "console.log('Verification process has started')", but surprisingly, this did not appear in the logs either.

Here is the Verification code snippet:

const { DiscordAPIError } = require("discord.js");
const { execute } = require("./ping");

const Discord = require("discord.js")

module.exports = {
    name: 'verify',
    description: 'Let them verify',
    aliases: ['Verify', 'Verification'],
    async execute(client, message, args){
        console.log('Verification process has started.')
        if(!message.member.roles.cache.has('955164630936850483')) return;

        const channel = '954717049890955334'
        const memberRole = '955164944482058240'
        const verifyEmoji = '✅'

        let embed = new MessageEmbed()
        .setColor("GREEN")
        .setTitle('React To Verify!')
        .setDescription('React with "✅" to get verified in the server.')

        let messageEmbed = await message.channel.send({ embeds: [embed]})
        messageEmbed.react(verifyEmoji)

        client.on('messageReactionAdd', async (reaction. user))
            if (reaction.message.partial) await reaction.message.fetch();
            if (reaction.partial) await reaction.fetch();
            if (user.bot) return;
            if (!reaction.message.guild) return;  

            if(reaction.message.channel.id == channel) {
                if(reaction.emoji.name === verifyEmoji) {
                    await reaction.message.guild.members.cache.get(user.id).roles.add(memberRole);
                    await reaction.message.guild.members.cache.get(user.id).roles.remove('<@955185557544263721>');
                }
            }   else {
                    return;
            }
        }
    }

Below is the Main code snippet:

> const Discord = require("discord.js") require('dotenv').config();
> 
> const generateImage = require("./generateImage") const { MessageEmbed
> } = require("discord.js")
> 
> 
> const client = new Discord.Client({
>     intents: [
>         "GUILDS",
>         "GUILD_MESSAGES",
>         "GUILD_MEMBERS",
>         "GUILD_MESSAGES",
>         "GUILD_MESSAGE_REACTIONS"
>     ],
>     partials: [
>         "messageCreate",
>         "CHANNEL",
>         "REACTION"
>     ] });
> 
> // Prefix const prefix = '-';
> 
> const fs = require('fs');
> 
> client.commands = []
> 
> // Command file filter for (const file of
> fs.readdirSync('./commands')) {
>     const command = require(`./commands/${file}`);
> 
>     client.commands.push(command); }
> 
> // Message when bot starts up client.once('ready', () => {
>     console.log('<Omnia> is online!');
>     client.channels.cache.get(`955163442472419460`).send(`I am now back online, if you see me offline contact staff in
> <#955167864422301736>.`) });
> 
> // Automatically gives "Unverified" when someone joins the server
> 
> 
> client.on("message", async message => {
>     if (message.author.bot) return false;
>     const Role1 = message.guild.roles.cache.get("RoleID");
> 
> 
> })
> 
> // Prefix filter client.on('message', message =>{
>     if (!message.content.startsWith(prefix) || message.author.bot) return;
>     const args = message.content.slice(prefix.length).split(/ +/);
>     const command = args.shift().toLowerCase();
> 
>     // Go through all the commands the bot has
>     for (const cmd of client.commands) {
>         // Check if the command name matches any of the aliases
>         if (cmd.aliases.includes(command)) {
>             // TODO: Check if the command has the required permissions
>             
>             // If the command is found, run it
>             cmd.execute(client, message, args)
>         }
>     } });
> 
> const welcomeChannelId = "954724625076600872"
> 
> client.on("guildMemberAdd", async (member) => {
>     const img = await generateImage(member);
>     member.guild.channels.cache.get(welcomeChannelId).send({
>         content: `<@${member.id}> *Make sure to invite your friends!*`,
>         files: [img]
>     }) }) client.login(process.env.DISCORD_TOKEN);

Answer №1

The issue arose when my code displayed

async execute(client, message, args){
instead of
execute: (client, message, args) =>{

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

Running on Node.js, the Promise is activated, yet there remains an issue with the function

I've encountered a strange issue that I can't seem to diagnose. It's showing a TypeError: My code is returning 'function is undefined', which causes the API call to fail. But oddly enough, when I check the logs and breakpoints, it ...

Team members

Just started diving into Angular and practicing coding with it while following video tutorials. However, I've stumbled upon something in my code that has left me puzzled. I'm curious about the significance of the line "employees: Employee[]" in ...

Combining Google app endpoints with a phonegap app: Step-by-step guide

I've been working on a Phonegap client application and have developed all the necessary web services using Google Endpoints. However, I am facing an issue with using the API. In my index.html file, there is this script: <head><script> ...

What is the best way to set a newly selected HTML option as the first choice?

I'm facing a simple problem in JavaScript that I can't seem to crack. Admittedly, I am new to working with JavaScript. My issue lies with sorting a dropdown list in alphabetical order while also keeping the selected value at the top. Whenever a ...

React-Redux Error: The function this.props.AppendCharacter is not defined

I have been looking for a solution to my issue but couldn't find anything that matches it. I am working on creating a calculator app using React & Redux, and whenever I click on one of the number buttons, I receive an error message saying "this.props. ...

Looping through a Vue Bootstrap modal using a v-for directive

I am working on a Vue Bootstrap modal placed within a v-for loop. I need to replace the '1' in both 'v-b-modal.modal-1' and 'modal-1' with the index value, which I can access as {{ index }} while looping through the items. How ...

Is there a way to trigger a function for both a left and middle click at the same time?

Check out this code snippet: $('a').on('click', function(){ myfunc($(this)); }); function myfunc(el){ console.log('Either left or middle click clicked on the link'); } a{ cursor: pointer; } <script src="https://aj ...

How to Insert <ul></ul> After Every Other <li> Element Using Angular's ngRepeat

With my current setup, I have a list item (li) within a list (ul) and applied ngRepeart. However, I would like to create a new ul after every 2nd li. Is this possible with AngularJS? <ul> <li>simth</li> <li>aryan</li> < ...

The result of Ajax is coming back as unclear

I've encountered an issue while trying to upload an image to my server using a POST form and AJAX. Every time I submit the form, my AJAX response shows as undefined in the error box. Here is the Ajax function I am referring to: $('.register_subm ...

Issue: Package 'cairo' not located on EC2 Bitnami MEAN server

Setting up my MEAN application on a Bitnami server has been quite a challenge. During the installation of dependencies, I encountered an error that I just can't seem to resolve. Despite following the instructions provided in the error message, I am st ...

Unable to reach the top while perfectly centered

I am currently struggling to create a perfectly centered popup menu that allows me to scroll all the way to the top. It seems like the transform property only affects visuals, so even though #content is set to top: 50%, I can't see everything at the t ...

Ways to retrieve the specified data in Javascript in string format

I'm facing an issue where the data I passed from a JavaScript array to a Java servlet and back to JavaScript is showing as "undefined." Check out my JavaScript code below: var buildingNumbers = []; // Let's assume the values of buildingNumbers ...

The result of JWT.decode may be null

I am facing an issue with decoding a JSON web token as it is returning null. I have even tried setting complete set to true, but unfortunately it still fails. The function used for generating the token is: import jwt from 'jsonwebtoken'; jwt.s ...

Showing the number of times a button has been pressed

I have written some HTML code to create a button and now I am looking for guidance on how I can use Vue.js to track how many times the button has been clicked. Here is what I have so far: <div class="123"> <button id = "Abutton&q ...

jquery is unable to fetch the input value from a dynamically generated field inside a function

Something peculiar keeps happening to me when I utilize jQuery, which is different from what others have encountered in the forums. Whenever I make an ajax call and generate an input element (on success), like so: Start Date: <input type="text" id="gr ...

Optimizing the Placement of Dynamic Google Maps

After setting up a responsive Google map using this jsFiddle and guidance from this stack overflow post, I encountered an issue. How can I keep the map centered on the marker across various viewports and browser sizes? I came across a solution in this res ...

How to Apply a CSS Class to the Body Tag in Angular 2.x

How can I add [class.fixed]="isFixed" to the body tag when Angular 2.x is bootstrapped inside the body (outside my-app)? <html> <head> </head> <body [class.fixed]="isFixed"> <my-app>Loading...</my-app> </body> & ...

ridiculing callback within parameter

I have a model setup in the following way: export class MyClass { grpcClient: MyGRPCClient; constructor(config: MyGRPCClientConfig) { this.grpcClient = new MyGRPCClient( config.serverUrl, grpc.credentials.createInsecure(), ); ...

Trigger a function upon the initial keypress event detected on an input field

I am facing an issue with an input element that has an onkeypress event triggering a function called change(). Strangely, the function does not execute on the very first keypress. I notice that I have to input 55 instead of just 5 for the function to updat ...

Trigger animation when the scroll position reaches 0.52 in Next.js using framer-motion

I’m working on a landing page and I have a section where I’d like to create a simple opacity animation using framer-motion. The issue is that these animations typically trigger as soon as you land on the page, but I want them to be based on scroll pos ...