List member (Question resolved)

How do I get a list of members in a guild? I need the names of the participants, I would like to get everyone. discord v 14
53 Replies
d.js toolkit
d.js toolkit7mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
Mapache2212 Games
My code:
client.on("messageCreate", opa => {
if(opa.content == 'teti') {
let geti = opa.guild.members.cache.find(member => console.log(member.user.username));


}
})
client.on("messageCreate", opa => {
if(opa.content == 'teti') {
let geti = opa.guild.members.cache.find(member => console.log(member.user.username));


}
})
Mapache2212 Games
What i want:
Danial
Danial7mo ago
Do you wanna have an option like that or do you just want all the members in the guild?
Mapache2212 Games
I need all members To add in choice
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
I don't use SlashBuilder
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs7mo ago
guide Message Components: Select menus - Auto-populating select menus read more
Mapache2212 Games
I have
Const command = {
name: test,
description: "this test"
option: {
choice: [
name: user,
value: *here code*
],
[
name: user,
value: *here code*
]}

}
Const command = {
name: test,
description: "this test"
option: {
choice: [
name: user,
value: *here code*
],
[
name: user,
value: *here code*
]}

}
Danial
Danial7mo ago
You don't use the SlashCommandBuilder or slash commands themselves?
Mapache2212 Games
I use Rest
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
I found these options on the forums, and I used them and they work.
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Danial
Danial7mo ago
That's not valid JavaScript though
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Under Ctrl
YouTube
Register and Run Slash Commands (Discord.js v14)
Register and Run Slash Commands (Discord.js v14) 🌐 Important links: Discord.js series playlist: https://www.youtube.com/playlist?list=PLpmb-7WxPhe0ZVpH9pxT5MtC4heqej8Es Discord.js official website: https://discord.js.org Discord Commands Structure: https://discord.com/developers/docs/interactions/application-commands#slash-commands (Options & ...
Mapache2212 Games
But new Rest it's working
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
I know JavaScript but I'm studying this library and I don't understand everything
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Danial
Danial7mo ago
^ That's the best and most up-to-date resource for you
Mapache2212 Games
Not everything worked for me as in the guide
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Slash command creator not working in guide
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
I don't understand your question
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Command handler
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
The tutorial shows that the command handler searches only for a folder with a specific name, I would like to remake this handler for myself. But I don't understand how it works.
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Yes
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
const foldersPath = path.join(__dirname, 'commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {
const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}
This I don't understand
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
I completed the entire Javascript tutorial learn.javascript.com
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
._.
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
If I didn’t understand something, I always searched on the Internet or asked a friend Ok
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
. They didn't answer my question My quietion: How do I get a list of members in a guild? I need the names of the participants, I would like to get everyone
d.js docs
d.js docs7mo ago
method GuildMemberManager#fetch() Fetches member(s) from a guild.
Danial
Danial7mo ago
await the Promise it returns, and then it'll be a collection of all the members in the guild, map over it to get their usernames or whatever
Mapache2212 Games
thx I undestand
client.on("messageCreate", opa => {
if (opa.content === 'teti') {
let guild = opa.guild;
guild.members.fetch().then(members => {
members.forEach(member => {
console.log(member.user.username);
});
}).catch(console.error);
}
});
client.on("messageCreate", opa => {
if (opa.content === 'teti') {
let guild = opa.guild;
guild.members.fetch().then(members => {
members.forEach(member => {
console.log(member.user.username);
});
}).catch(console.error);
}
});
and you thank you @Alexcitten
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
could have connect it into my code .
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Okay, that's your opinion. The matter is closed.
Unknown User
Unknown User7mo ago
Message Not Public
Sign In & Join Server To View