Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

121
Vistas
Cant grap component of array within a for loop

I try to compare all user id's who have reacted to a message with another array. To do so I have fetched all users who have reacted and now I try to loop trough them, but I don't get the entries.

async function compare() {

//fetch reactions
    const channel = await interaction.client.channels.fetch(rewardchannel) 
    const message = await channel.messages.fetch(rewardpannel)
    const reaction = message.reactions.cache.get('✅')
    const users = await reaction.users.fetch()

//check users
    console.log(users) //1.

//loop through users
    for await (const user of users){
        console.log(user.id) //2.
    }
}

The 1. log should display the users array and work as it supposed to. The result is:

Collection(3) [Map] {
  '360053737638723584' => User {
    id: '360053737638723584',
    bot: false,
    system: false,
    flags: UserFlags { bitfield: 0 },
    username: 'Hell FIre',
    discriminator: '7210',
    avatar: '4ea6126903e68309b6dc2f7c22c8e30c',
    banner: undefined,
    accentColor: undefined
  },
  '964592219745050645' => User {
    id: '964592219745050645',
    bot: false,
    system: false,
    flags: UserFlags { bitfield: 0 },
    username: 'sola.eth',
    discriminator: '6722',
    avatar: 'bb3a9026ef8314e4f6be5228e1c955b0',
    banner: undefined,
    accentColor: undefined
  },
  '973154369233096717' => ClientUser {
    id: '973154369233096717',
    bot: true,
    system: false,
    flags: UserFlags { bitfield: 0 },
    username: 'Retweet Rewards',
    discriminator: '7150',
    avatar: null,
    banner: undefined,
    accentColor: undefined,
    verified: true,
    mfaEnabled: true
  }
}

However the 2. loop only returns undefined 3 times. So it is correctly looping through but it dont grap the acctual id of a user. Where is my mistake ?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Mapping the array of objects will go through each object.

// log users
users.map(user => {
  console.log(user.id);
})
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda