Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
How can send data from an array in one embed message (discord.js)

I want to send data from an array in one embed message with few fields but my code sends them as 4 different embed messages with one field

I tried with this Code :

    const pListEmbed = new Discord.MessageEmbed()
                    .setColor('#03fc41')
                    .setTitle('Connected')
                    .setDescription(Total : ${list.length})
                    .setThumbnail(config.logo)
                    .addFields(
  array.flatMap(user => [
    { name: 'ID', value: user.id, inline: true },
    { name: 'Name', value: user.user_name, inline: true },
    { name: 'Identifier', value: user.identifier, inline: true }
  ])
)

                    )
                    .setTimestamp(new Date())
                    .setFooter('Used by: ' + message.author.tag, ${config.SERVER_LOGO});

                message.channel.send(pListEmbed);

But it sends 4 embed messages with just one field that have id,username and identifier, and i don't want it like this. I want it to send one embed message with 4 different fields that have these 4 id,username and identifiers (we don't know how many of them we have)

Array :

    [
        {
      id: '46892319372',
      user_name: 'testerOne',
      identifier: '20202'
    }
]
[
    {
      id: '15243879678',
      user_name: 'testerTwo',
      identifier: '20201'
    }
]
[
    {
      id: '02857428679',
      user_name: 'testerThree',
      identifier: '20203'
    }
]
[
    {
      id: '65284759703',
      user_name: 'testerFour',
      identifier: '20204'
    }
]
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your question is very unclear. If you want to send one embed for every user containing the ID, name and identifier, then you could do this:

list.forEach(user => {
 const pListEmbed = new Discord.MessageEmbed()
                    .setColor('#03fc41')
                    .setTitle('Connected')
                    .setDescription(Total : ${list.length})
                    .setThumbnail(config.logo)
                    .setTimestamp(new Date())
                    .setFooter('Used by: ' + message.author.tag, ${config.SERVER_LOGO});
                    .addFields(
                       {
                          name: "ID"
                          value: user.id,
                          inline: true
                       },
                       {
                          name: "Name"
                          value: user.user_name,
                          inline: true
                       },
                       {
                          name: "Identifier"
                          value: user.identifier,
                          inline: true
                       }
                    )

                message.channel.send(pListEmbed);
})

If on the other hand you want to send one embed only and it contains all the IDs, all the names, and all the identifiers, then this is impossible. Embed have character limits and since you don't know how many users you have, there could be thousands, thus busting the limit. And that would block you from sending the embed.

Also your "array" is in fact multiple arrays containing only one element each. I don't know if that's what you intended or not but it's not an array but multiple little ones.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda