'Discord.js Is there any way to get all users to separate variables?
Is there any way to get all id's of users in one server to separate variables?
Solution 1:[1]
Yes, kind. You could loop through with a for loop then run whatever code you want to on the desired user.
// Where '888888888888888888' is your server id
const server = client.guilds.get("888888888888888888");
// Go through each of the members, and console.log() their name
server.members.forEach(member => console.log(member.user.username));
//Replace console.log() with what you want to do to them. (e.x give role, ban, kick, dm)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |