【发布时间】:2020-08-18 19:58:16
【问题描述】:
当我正确完成所有操作并正确编写脚本时,当我放置 node 时会出现。在命令提示符下,我什至有一个有效的令牌!! ::
(node:8744) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided. at Client.login (C:\Users\User\Documents\GitHub TigerDuo\TigerDuo\node_modules\discord.js\src\client\Client.js:204:52) at Object.<anonymous> (C:\Users\User\Documents\GitHub TigerDuo\TigerDuo\index.js:47:5) at Module._compile (internal/modules/cjs/loader.js:1133:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10) at Module.load (internal/modules/cjs/loader.js:977:32) at Function.Module._load (internal/modules/cjs/loader.js:877:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12) at internal/main/run_main_module.js:18:47 (node:8744) 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:8744) [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.
这是我的脚本,更不用说我设置了 heroku 和 github:
const Discord = require('discord.js');
const bot = new Discord.Client();
const token = 'MyNeverToBeSharedToken';
bot.on('ready', () => {
console.log('Online.')
bot.user.setActivity('the Tiger Duo server!', {
type: "WATCHING"
})
bot.login(process.env.token);
【问题讨论】:
-
您需要更新您的令牌,并且不再共享它,这就像共享您的密码
-
您似乎发布了敏感/私人信息。请重置您的密码和/或撤销 API 密钥和令牌,因为它们在互联网上发布时被视为已泄露。如果发布了个人身份信息,请edit 删除信息,然后标记您的帖子以供版主编辑修订。