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 toolkit12mo 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
Mapache2212 GamesOP12mo ago
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
Mapache2212 GamesOP12mo ago
No description
Mapache2212 Games
Mapache2212 GamesOP12mo ago
What i want:
Danial
Danial12mo ago
Do you wanna have an option like that or do you just want all the members in the guild?
Mapache2212 Games
Mapache2212 GamesOP12mo ago
I need all members To add in choice
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
I don't use SlashBuilder
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs12mo ago
guide Message Components: Select menus - Auto-populating select menus read more
Mapache2212 Games
Mapache2212 GamesOP12mo ago
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
Danial12mo ago
You don't use the SlashCommandBuilder or slash commands themselves?
Mapache2212 Games
Mapache2212 GamesOP12mo ago
I use Rest
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
I found these options on the forums, and I used them and they work.
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Danial
Danial12mo ago
That's not valid JavaScript though
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
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
Mapache2212 GamesOP12mo ago
But new Rest it's working
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
I know JavaScript but I'm studying this library and I don't understand everything
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Danial
Danial12mo ago
^ That's the best and most up-to-date resource for you
Mapache2212 Games
Mapache2212 GamesOP12mo ago
Not everything worked for me as in the guide
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
Slash command creator not working in guide
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
I don't understand your question
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
Command handler
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
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 User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
Yes
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
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 User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
I completed the entire Javascript tutorial learn.javascript.com
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
._.
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
If I didn’t understand something, I always searched on the Internet or asked a friend Ok
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
. 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 docs12mo ago
method GuildMemberManager#fetch() Fetches member(s) from a guild.
Danial
Danial12mo 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
Mapache2212 GamesOP12mo ago
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 User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
could have connect it into my code .
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Mapache2212 Games
Mapache2212 GamesOP12mo ago
Okay, that's your opinion. The matter is closed.
Unknown User
Unknown User12mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server