因此,我试图使用Heroku托管一个不和谐的bot,并且我已将配置变量和所有内容都设置在Heroku中。但是当我做client.login(process.env.TOKEN)
时,它给了我这个错误:
(node:14392) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (C:\Users\hello\Documents\Programming\Discord\Vibes\node_modules\discord.js\src\client\Client.js:205:52)
at Object.<anonymous> (C:\Users\hello\Documents\Programming\Discord\Vibes\index.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.
我已经在网上进行了调查,但是找不到一个对我有帮助的答案。
答案 0 :(得分:0)
可以显示.env文件中的内容吗?
TOKEN=""
如果它不起作用,请尝试使用令牌替换“ process.env.TOKEN”,如果该令牌也不起作用,则该令牌是错误的。
答案 1 :(得分:0)
使用:: Dot Env
require('dotenv').config()
console.log(process.env.TOKEN)
您可能会遇到多行字符串值的问题。这可能是一个问题,我在使用证书密钥时遇到了这个问题。尝试检查它是否可以正确读取一行值。