UnhandledPromiseRejectionWarning: DiscordjsError: Request to use token, but token was unavailable to the client

148 Views Asked by At

Hey im making a leaderboard command with discord-xp but when i run the command it gives the following error:

(node:7400) UnhandledPromiseRejectionWarning: DiscordjsError: Request to use token, but token was unavailable to the client.
    at RequestHandler.execute (C:\Users\niels\Documents\VsCode Projects\Discord Bots\flat8\node_modules\discord.js\src\rest\RequestHandler.js:93:15)
    at RequestHandler.execute (C:\Users\niels\Documents\VsCode Projects\Discord Bots\flat8\node_modules\discord.js\src\rest\RequestHandler.js:97:19)
    at RequestHandler.push (C:\Users\niels\Documents\VsCode Projects\Discord Bots\flat8\node_modules\discord.js\src\rest\RequestHandler.js:39:25)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async UserManager.fetch (C:\Users\niels\Documents\VsCode Projects\Discord Bots\flat8\node_modules\discord.js\src\managers\UserManager.js:67:18)        
    at async Function.computeLeaderboard (C:\Users\niels\Documents\VsCode Projects\Discord Bots\flat8\node_modules\discord-xp\index.js:275:30)
    at async callback (C:\Users\niels\Documents\VsCode Projects\Discord Bots\flat8\commands\leveling\leaderboard.js:13:29)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:7400) 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:7400) [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.

my code

can anyone help me with this?

1

There are 1 best solutions below

1
On BEST ANSWER


It looks like you're trying to perform an action but your client isn't logged in. Maybe you can find help here:
https://discordjs.guide/popular-topics/errors.html#request-to-use-token-but-token-was-unavailable-to-the-client
Hope I could help
ShadowLp174

[Edit] Sry, link was broken - fixed it ;)