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

551
Vistas
How to get multiple message IDs in discord.js?

My bot sends 3 messages following eachother and I need to save their IDs, because I need to edit them later. If I do something like this:

message.channel.send(`${acc[player].output.slot1}`).then((m) => {
  acc[player].ids.msg1 = m.id
})
  
message.channel.send(`${acc[player].output.slot2}`).then((n) => {
  acc[player].ids.msg2 = n.id
})
    
message.channel.send(`${acc[player].output.slot3}`).then((o) => {
  acc[player].ids.msg3 = o.id
})

all three will have the 3rd one's ID. Slowing down the process or doing it step by step didn't help.

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

0

Not sure why all 3 entries would result in the same value, however maybe handling the promises differently could help. Try awaiting Promise.all() with an array of the send messages and map all the results to the id.

const { send } = message.channel;

try {
   (await Promise.all([
      send(`${acc[player].slot1}`),
      send(`${acc[player].slot2}`),
      send(`${acc[player].slot3}`)
   ])).forEach((msg, i) => {
      acc.player.ids[`msg${i + 1}`] = msg.id;
   });
} catch (err) {
   console.error(err);
}
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