由于令牌无效,无法启动discord bot



所以我正试图使用Heroku托管一个discord bot,并且我在Heroku中设置了我的配置变量和所有内容。但当我执行client.login(process.env.TOKEN)时,它会给我一个错误:

(node:14392) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (C:UsershelloDocumentsProgrammingDiscordVibesnode_modulesdiscord.jssrcclientClient.js:205:52)
at Object.<anonymous> (C:UsershelloDocumentsProgrammingDiscordVibesindex.js:14:8)
at Module._compile (internal/modules/cjs/loader.js:1256:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1277:10)
at Module.load (internal/modules/cjs/loader.js:1105:32)
at Function.Module._load (internal/modules/cjs/loader.js:967:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
(Use `node --trace-warnings ...` to show where the warning was created)
(node:14392) 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: 1)
(node:14392) [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.

我在网上研究过,但没有找到对我有帮助的答案

使用::点环境

require('dotenv').config()
console.log(process.env.TOKEN)

您可能会遇到多行字符串值的问题。这可能是个问题,我的证书密钥有这个问题。试着检查它是否能正确读取一行值。

您能显示.env文件中的内容吗TOKEN=""

如果它不起作用,请尝试用令牌替换"process.env.TOKEN"。如果它也不起作用则令牌是错误的。

最新更新