javascript - Unable to launch discord bot due to invalid token
问题描述
So I am trying to host a discord bot using Heroku, and I have my config variables and everything set up in Heroku. But when I do client.login(process.env.TOKEN)
, it gives me this error:
(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.
I've researched online, but I haven't found an answer that helps me.
解决方案
使用::点环境
require('dotenv').config()
console.log(process.env.TOKEN)
而且您可能会遇到多行字符串值的问题。这可能是一个问题,我遇到了证书密钥的问题。尝试检查它是否可以正确读取一行值。
推荐阅读
- qt - 如何禁用 qInfo() 输出
- python - 从文件导入功能(django)
- javascript - 表单制作器的 Javascript 函数可以在常规 html 中运行吗
- r - 重新安排一个令人不快的实际工作数据框架以在 r 中进行时间序列分析
- python - 使用 Pandas,您只能从显示日期范围(2020-02-10/2020-02-16)的 to_period 函数中提取日期吗?
- apache-flink - Flink 日志记录 - 使用 Log4j2
- typescript - 绝对导入 typescript 部分反应原生作品
- visual-studio-code - 选择目标应用程序 vscode
- google-cloud-platform - Neoj4 GCP 错误:“在此服务器上找不到请求的 URL /v1/documents:classifyText?key=apiKey”
- python - venv什么时候需要激活?