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

313
Vistas
Using JavaScript, how can I pull info from a database and order it in a list?

I have a rough idea on how to do this, but it doesn't seem to be working too well.

What I have already achieved is pulling all of the data necessary that needs ordered. What I need is a way to take all of that information and order it from the highest number to the lowest number, and then display that in a single embed - without the use of adding more fields. Ideally it should look something like the image included, except inside an embed. I want to be able to loop this so that it automatically updates the message every X amount of seconds with a message edit.

Each row is ordered from #1 to #20 with #1 having the most Points. This is in the [0123] bit.

The code used to select data from the table is:

const [team, teamd, teame] = await pool.query("SELECT * FROM `performancetracker`.`leaderboard`");

The columns I have use for are TeamName and Points.

I've done something similar with the following code:

      Object.keys(check).forEach(function(key) {
    var row = check[key];
    let name = row.TeamName
  embed1.addField(`Team:`, `${name}`, true)
  })

However, this adds fields to the embed, which I don't want. I'm not too sure how to go about creating an array or object that I can add to and edit later in the code while maintaining the ability to add it as a field in an embed. I'm not fluent with JavaScript, I'm still learning new things and finding new challenges.

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

0

I'm not sure I can help you with the updating part because I don't fully understand the question, but you can do this for displaying the embed how you want:

let data;
Object.keys(check).forEach(() => {
    var row = check[key];
    let name = row.TeamName
    data += `Team: ${name}\n`
})
embed1.addDescription(data)

I haven't tested this code, but it should work.

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