JavaScript 通过 Discord-XP 的 Discord 机器人级别系统

JavaScript Discord Bot Level System through Discord-XP

当我执行 !leaderboard 命令时,我会收到错误消息。我有 leaderboard.js 文件的代码:

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")}`);
     
    }
}

这是我得到的错误:

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)

我已经尽我所能,在网络上搜索了很长时间,但我无法解决错误。

我是 JavaScript 的新手,所以不知道现在该怎么做。

我检查了那个 discord-xp 库的源代码,你的客户端似乎是一个虚假值(很可能是未定义的)。确保您的功能正确执行

command.execute(message, args, client)

其中 所有 3 个参数,按此顺序