MrAugu/discord-xp

Error with computeLeaderboard

Closed this issue · 1 comments

I get this error

(node:16100) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'fetch' of undefined
at Function.computeLeaderboard (C:\Users\Stijn Dusseldorp\Desktop\Code\Discord-Bot\node_modules\discord-xp\index.js:271:41)
at Object.execute (C:\Users\Stijn Dusseldorp\Desktop\Code\Discord-Bot\commands\leaderboard.js:11:42)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use node --trace-warnings ... to show where the warning was created)
(node:16100) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:16100) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

When I execute this piece of code
`const Levels = require('discord-xp')

module.exports = {
name: 'leaderboard',
description: 'Displays the servers top 10 leveled users',
async execute(message, args, Discord, client) {
const rawLeaderboard = await Levels.fetchLeaderboard(message.guild.id, 10); // We grab top 10 users with most xp in the current server.

    if (rawLeaderboard.length < 1) return reply("Nobody's in leaderboard yet.");
    
    const leaderboard = await Levels.computeLeaderboard(client, rawLeaderboard, true); // 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")}`);}

}`

Join our discord server : https://discord.gg/aP9UYfaFa4
And make a ticket.
When doing so provide your complete error and your current code.