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

404
Vistas
How to post the JSON data in a embed in discord.js

I wrote a code and i got the data in a json format. Now i want it to convert that data into a discord embed so that when i enter a command . EX:- .data the json data to be sent from the URL.

Here is the input

request({
    url: "https://data.vatsim.net/v3/vatsim-data.json",
    json: true

}, (err, response, body) => {
    console.log(body)

})

The json data looks like this :

    {
      cid: 1435807,
      name: ' ',
      callsign: 'ZAP85LJ',
      flight_plan: [Object],
      last_updated: '2021-10-24T10:45:52.516736Z'
    },
    {
      cid: 1439854,
      name: ' ',
      callsign: 'DLH1ML',
      flight_plan: [Object],
      last_updated: '2021-10-24T10:46:13.4226778Z'
    }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use EmbedFields, you can use up to 25 fields on an embed. On this example I used .forEach so that for each element on the array I can create a field with its value:

request({
  url: "https://data.vatsim.net/v3/vatsim-data.json",
  json: true
}, (err, response, body) => {
      const embed = new Discord.MessageEmbed()
      const pilots = body.pilots.slice(0, 15)
      body.pilots.forEach(pilot => {
        embed.addField(p.name,
          `CID : ${p.cid}
Server : ${p.server}
etc...`)
      })
      message.channel.send(embed)
}

If you really want to show every single one of your elements on the array you can use discord-buttons to make the embed edit its message and change pages but for now this is the simplest and easiest solution for you.

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