I have a query
let true_members = interaction.guild.members.cache.filter((member) => !member.user.bot).size;
to retrieve all non-bot members on a server, however it consistently returns the value of 1. (Using a Slash command).
I have a query
let true_members = interaction.guild.members.cache.filter((member) => !member.user.bot).size;
to retrieve all non-bot members on a server, however it consistently returns the value of 1. (Using a Slash command).
Retrieve the first names of all GuildMembers and filter out those who are bots.
let real_members;
interaction.guild.members.fetch().then(all_members => {
real_members = all_members.filter(member => !member.user.bot);
});
console.log(real_members.size);
Make sure to include Intents.FLAGS.GUILD_MEMBERS
in your client's intents and enable it in your Discord developer portal.
Check out Discord.JS Collection Utility Functions for more information.
Have you considered using ".fetch" like this:
interaction.guild.members.fetch()
.then ((members) => {
const ActiveMembers = members.filter((member) => !member.user.bot).size
})
CAUTION: CODE HAS NOT BEEN TESTED
If you want to access the data outside, either declare a variable globally or convert it into a function and return the value.
function getActiveMembers (interaction) {
interaction.guild.members.fetch()
.then ((members) => {
members.filter((member) => !member.user.bot).size
.then((Count) => {
return Count
})
})
};
const ActiveMembersCount = getActiveMembers(interaction);
Simply provide the interaction as an argument.
I am facing a challenge with my collection as I need to perform aggregation using only JavaScript. I have attempted various approaches utilizing the Lodash library but unfortunately, I have not been successful. If you could provide me with some guidance on ...
Is there a way to determine if a specific date is at least one day (24 hours) in the past using momentjs? For example: const currentDate = moment() const isAtLeastOneDayAgo = currentDate.subtract(dateToVerify) > 1 // How can this be done? ...
How can I search indexOf in an array of elements with only one specific element from the same class? class Dhash { constructor(Dlable, tophash) { this.Dlable = Dlable; this.tophash = tophash; } } let listohashs = []; listohashs[0] = new Dhash(0 ...
I am currently working on a straightforward example where I have a file input field and a text input field. The goal is to update the text input with the value of the selected file once a file is chosen. Here is an overview of my code: <input id="sele ...
I'm experiencing memory problems with file uploads while hosting my site on NodeJitsu. When I try to upload files, my app crashes with this error message: { [Error: spawn ENOMEM] code: 'ENOMEM', errno: 'ENOMEM', syscall: 'spa ...
Is it possible to use JQuery to select text from list elements? I am looking for similar functionality as the .select() in plain javascript, but this method only works for editable text areas/input boxes. Can anyone provide guidance on achieving the same f ...
When working in the main project directory, running the command npm init will create a file called "package.json". If I need to install dependencies such as angular, jQuery and bootstrap, I can use the following commands: npm install angular --save-de ...
I searched extensively for a solution to this query, but came up empty-handed. My situation involves a PHP-generated page that creates a JSON string. This string is then retrieved by javascript/jQuery/AJAX. I am faced with the challenge of displaying a m ...
Exploring the combination of different data types using a simple addition function. For instance, when adding 1 + 1, we expect to get 2, and when adding 1 + "one", the result should be "1one". Below is the content of my functions.js file: module.exports = ...
Despite my efforts to troubleshoot, I am still encountering a frustrating issue with the Three.js API. Even after thoroughly studying the API documentation, browsing through StackOverflow questions, and using debugging tools like firebug and chrome's ...
When it comes to creating a promise in Kris Kowal's q library, most developers are familiar with using var defer = Q.defer();, along with calling defer.resolve(); and/or defer.reject() to return defer.promise. However, upon further examination of the ...
Here is a sample component code snippet: import { Component, OnInit, Input } from '@angular/core'; import { Observable } from 'rxjs/Rx'; @Component({ selector: 'chart', templateUrl: 'app/comps/chart.html', ...
I'm currently working on a solution for chaining 3 ajax calls where the result of one call feeds into the next two. Here's the scenario: // Invoke the ajax calls firstAjax('mypage.gng','john-doe').then(secondAjax, thirdAjax) ...
I'm currently working on a project that involves sending a URL to multiple websites for categorization and security risk scanning using Java and HtmlUnit. I have configured all the websites except www.virustotal.com, where I'm facing a challenge ...
Instead of simply copying example code from tutorials, I am challenging myself to grasp ES6 Promises by implementing them in a meaningful way within a real project. Below is the frontend Vue.js/axios code I created that effectively utilizes Promises to po ...
Here is the code snippet I am working with: signin(context, payload, resolve) { console.log("Processing SIGNIN action") const userEmail = payload.locmail const userPassword = payload.locpass backend.get("api/auth/signin", { headers ...
When utilizing the autoimport feature of Nuxt 3: Are there any implications (such as types, performance, bundle size, tree shaking, etc.) when using the # alias to import something as opposed to not importing at all? Or is its sole purpose to provide expl ...
After extensive research, I have been unable to find any information on the issue at hand. I am attempting to use the jquery plugin OkVideo to display different videos in two separate "section" tags. However, even after explicitly assigning IDs to each con ...
Is it possible to write a method that is an extension of a base class, but with a different return type, if supported by the shared interface, without adding a type declaration in class 'a'? In practical terms, classes a & b exist in JavaScript ...
I have a task to create unique groups of 7 elements from an array of 49 and determine the number of possible outputs. For example: [A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y] The desired outputs are ...