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

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

嘿,我正在使用 discord-xp 创建排行榜命令,但是当我 运行 命令时,它会出现以下错误:

(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

谁能帮我解决这个问题?


您似乎正在尝试执行某项操作,但您的客户端尚未登录。也许您可以在这里找到帮助:
https://discordjs.guide/popular-topics/errors.html#request-to-use-token-but-token-was-unavailable-to-the-client
希望我能帮上忙
ShadowLp174

[编辑] 抱歉,link 已损坏 - 已修复 ;)