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

177
Vistas
JavaScript Discord Bot Level System through Discord-XP

When I do command !leaderboard I'll get an error. I have this code for the leaderboard.js file:

const Levels = require('discord-xp');
module.exports = {
    name: 'leaderboard',
    description: 'Leaderboard Command :)',
    async execute(message, args, client){
        const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 5); // We grab top 10 users with most xp in the current server.

        if (rawLeaderboard.length < 1) return reply("Nikdo není v žebříčku.");

        const leaderboard = await Levels.computeLeaderboard(client, rawLeaderboard); // We process the leaderboard.

        const lb = leaderboard.map(e => `${e.position}. ${e.username}#${e.discriminator}\nLevel: ${e.level}\nXP: ${e.xp.toLocaleString()}`); // We map the outputs.

        message.channel.send(`**Leaderboard**:\n\n${lb.join("\n\n")}`);
     
    }
}

This is the error I get:

C:\Users\xb06\Desktop\Sanoy\node_modules\discord-xp\index.js:262
    if (!client) throw new TypeError("A client was not provided.");
                       ^

TypeError: A client was not provided.
    at Function.computeLeaderboard (C:\Users\xb06\Desktop\Sanoy\node_modules\discord-xp\index.js:262:24)
    at Object.execute (C:\Users\xb06\Desktop\Sanoy\commands\leaderboard.js:10:42)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I've tried everything I could, searched on web, and so long, but I can'ť resolve the error.

I am new to JavaScript so idk what to do now.

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

0

I checked the source code of that discord-xp library, and it seems that your client is a falsy value (most likely undefined). Make sure your function is being executed properly

command.execute(message, args, client)

With all 3 of those arguments, in that order

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