Error in Discord.js Bot giveaway command: .array() does not exist as a function

Struggling with creating a Discord.js giveaway command that involves sending an embed, saving it to the variable embedSent, collecting reactions post TimeOut using the reactions.get() method, converting them into an array with array(), and then filtering them with .filter(). The issue arises at the Array() step where I continuously encounter the error

TypeError: peopleReactedBot.array is not a function
.
Taking a look at the specific part of my code :

embedSent.react("🎉");
setTimeout(function () {
    try {
        const peopleReactedBot = embedSent.reactions.cache.get("🎉").users.fetch();
        const peopleReacted = peopleReactedBot.array().filter(u => u.id !== client.author.id);
        message.channel.send(peopleReacted)
    } catch(e) {
        return message.channel.send("An error has occured : `"+e+"`");
    }
}, time);

Using Discord.js v12.

Answer â„–1

user.fetch() is a Promise, so it's recommended to use an async function and await for the Promise to resolve. Here's how you can do it:

setTimeout(async () => {
    try {
        const botReactions = await message.reactions.cache.get("🎉").users.fetch();
        const userReactions = botReactions.array().filter(u => u.id !== client.user.id);
        message.channel.send(userReactions)
    } catch(error) {
        return message.channel.send("An error occurred: `"+error+"`");
    }
}, time);

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

Understanding the fundamentals of Handlebars IF statements

I am trying to accomplish a simple task in HBS, but I have hit a roadblock. How can I write a conditional statement for when the value is greater than 0? {{#if value > 0}} {{/if}} Additionally, does anyone have recommendations for a good HBS tutorial ...

Retrieving data from a database using twig

In my PHP code, I currently have the following: $vals['followers'][] = R::find('follow', 'following_id=?', array($_GET['id'])); This code returns all followers in the "follow" table with a following_id that matche ...

reloading a URL dynamically using an array in JavaScript

I need assistance with a Chrome extension code. The goal is to have it check the page that initially loads, and if it matches my website st.mywebsite.com, execute the specified code. Currently, it does not perform this check and runs on every loaded page ...

Antialiasing with Three.js appears to be malfunctioning specifically on iPhone 5 and iPhone 5s devices

As a newbie to three.js, I managed to finish my project successfully. To enhance the graphics quality, I decided to enable antialiasing. renderer = new THREE.WebGLRenderer( { antialias: true } ); Unfortunately, after enabling antialiasing on iPhone 5 and ...

Instead of pushing multiple items, focus on pushing only one item at a time

I've encountered an issue while attempting to add a new item to my favlist. Using a for loop, I check if the item already exists in the favlist. However, instead of adding the new item only once, it ends up being added multiple times. What would be ...

Creating a custom directive for input validation in Angular

I am currently working on building a basic custom directive in AngularJS to validate if the user input is an integer or not. When the user types in an integer, I want an error message to display at the bottom that states "integers are not allowed". Do yo ...

How to retrieve data from a GET request using node.js

I'm encountering a small issue with a Node application. The problem lies in a script on website "x" that calls a function from another server (like analytics) using ajax. When the function returns data, I notice something curious happening. While chec ...

Troubleshooting Rails 4: Handling a 404 Not Found Error When Making an AJAX Call to a

After spending about an hour trying to figure this out, I am still stuck... The action in my oferts_controller.rb file looks like this: def update_categories @categories = Category.children_of(Category.find(params[:categories])) respond_to ...

Prevent user input in HTML

Currently, I am working on creating the 8 puzzle box game using JavaScript and jQuery Mobile. The boxes have been set up with <input readonly></input> tags and placed within a 9x9 table. However, an issue arises when attempting to move a box ...

I am having trouble getting the minimum value as it keeps displaying 0. However, when using Math.max(), it correctly displays the maximum value. Can anyone explain why this is the case?

Why am I not getting the minimum value when it displays 0, but Math.max() correctly shows the maximum value? function findMin(ar) { var min_val = 0; for(var i = 0; i < ar.length; i++) { min_val = Math.min(min_val,ar[i]); } document.write(m ...

Using Javascript to convert an SVG file into DOM elements

Seeking assistance with uploading an SVG file and then inspecting or parsing it to utilize the elements and values within the DOM. After extensive searches, I've only found information on parsing from the DOM itself. Is this task feasible? If so, cou ...

Success Notification in ASP.net MVC after Form Submission

I am looking to implement a success alert pop-up or message after the form is submitted and action is successful. In this scenario, I want to display "successfully add": Create Action : [HttpPost] [ValidateAntiForgeryToken] public ActionResult Cr ...

Tips for integrating Twitter sharing functionality in React JS

I am looking for a way to enable users to easily share images from my website on Twitter. Although I tried using the react-share module, it does not provide an option to directly share images. This is the snippet of code I currently have: import { Sh ...

Why does my node-js API's second endpoint not function properly?

Currently working on my first API project. Everything was going smoothly, until I encountered an issue with my second route, app.route('characters/:characterId'). For some reason, none of the endpoints are functioning, while the first route, app. ...

Positioning the comments box on Facebook platform allows users to

Need assistance, I recently integrated the Facebook comments box into my Arabic website, but I am facing an issue where the position of the box keeps moving to the left. Here is an example of my website: Could someone please suggest a solution to fix the ...

One method I use to retrieve ajax data and assign it before rendering the view

Despite putting the ajax.get in the created function, I am still unable to retrieve the ap_name value. This issue is related to vue.js created: function () { ajax.get('/envs').then(function (res) { this.apName = res.AP_NAME; ...

I am looking to modify a particular value within an array of objects, but for some reason, the update is not being applied correctly

When attempting to copy the array, I update the selected value of a specific object based on the matching memberId. This process works well for a single member, however, issues arise when there are multiple members as the updating doesn't work correct ...

Navigating Next.js: Mastering the art of localStorage Access

Currently, I am developing my first member area using next.js. My goal is to store some data in localStorage (such as token, expiresAt, userInfo), which will eventually be moved to an http-only cookie. The code below is generating the error: "LocalStorage ...

Tips for successfully transferring a blob within a .run method

I've searched through the Google Apps Script Reference but couldn't find an answer to my question. Can a blob be passed through a .run() function in a Google script? Below is the code I am working with: Within my HTML file's script, there i ...

Developing web components using angular.js while ensuring compatibility with IE11

I have an angular.js application where I need to initialize a web component. Everything runs smoothly on different browsers, however IE11 seems to have problems with document.importNode The angular.js onInit function is as follows: vm.$onIni ...