#<Collection>.each

21 messages · Page 1 of 1 (latest)

regal geyserBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

covert shale
#

just do let memberArray = […role.members.values()]

covert shale
#

its three points not triple points

spring minnow
#

Just use .map()

mossy carbon
mossy carbon
covert shale
mossy carbon
covert shale
#

then do my method and map the array

#

.map(m=> ({id : m.id}))

brazen reef
#

Your js is terrible

let membersO = role.members.map(m => ({
    id: m.id,
    avatarURL: m.displayAvatarURL(),
    displayName: m.displayName,
    displayHexColor: m.displayHexColor,
  }));

staff.push(...membersO);
echo blaze
echo blaze
brazen reef
mossy carbon
#

yeah it's and I don't await it's call for some reasons, the code is currently look like this:

async function staffCache(client) {
  const guild = await client.guilds.fetch(serverID);
  let staff = []

  for (i = 0; i < staffRoles.length; i++) {

    const role = await guild.roles.fetch(staffRoles[i][1]);
    let members =  [...role.members.values()];

    staff.push(members.map(m=> ({id : m.id})));

  };

  await redisClient.set('staffData', JSON.stringify(staff));
  console.log('staff data have been updated.');
  setTimeout(()=>{staffCache(client)}, 60000 * 60);
}

the code is working fine, but the problem is that it does not show all the members who have these roles for unknown reasons.

#

output:

[
  [ { id: '193133466349469696' } ],
  [],
  [],
  [ { id: '222251985200611328' } ],
  [ { id: '222251985200611328' } ],
  [],
  [ { id: '483265262611857409' } ],
  [ { id: '323999863153098752' } ],
  [
    { id: '899265348178694184' },
    { id: '491352435223298058' },
    { id: '962943798940434452' }
  ],
  [ { id: '640847325945921536' } ]
]

the members having these roles are much more than those showing up

broken axle
#

Fetching a role doesnt mean that it will populate role.members

#

You would need to fetch all members from the guild using guild.members.fetch

mossy carbon
#

oh shit

broken axle
#

And collection.map exists