Discord 不一致,.js上的令牌无效

Discord 不一致,.js上的令牌无效,discord,discord.js,Discord,Discord.js,我最近启动了一个新的discord.js bot,出现了一个“无效令牌”错误。这不可能是因为异步函数,因为我只启动了bot,并且我有0个命令,上次发生这种情况是在我尝试在heroku上托管另一个bot时。我从未找到解决方案,这是我的终端: C:\Users\Lory\Desktop\pp>node . (node:3760) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provi

我最近启动了一个新的discord.js bot,出现了一个“无效令牌”错误。这不可能是因为异步函数,因为我只启动了bot,并且我有0个命令,上次发生这种情况是在我尝试在heroku上托管另一个bot时。我从未找到解决方案,这是我的终端:

C:\Users\Lory\Desktop\pp>node .
(node:3760) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
    at WebSocketManager.connect (C:\Users\Lory\Desktop\pp\node_modules\discord.js\src\client\websocket\WebSocketManager.js:133:26)
    at Client.login (C:\Users\Lory\Desktop\pp\node_modules\discord.js\src\client\Client.js:222:21)
(node:3760) 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:3760) [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.

C:\Users\Lory\Desktop\pp>
我正在使用的代码:

const Discord=require('Discord.js');
const client=new Discord.client();
常量前缀='!'
client.on('ready',()=>{
log('bot已就绪');
});
client.login('token');

提供的
令牌无效
出现错误,因为您在
.login()
中设置的令牌无效,或者由于垃圾邮件、恶意行为或不活动等原因被Discord撤销。还要确保在中创建了自己的bot应用程序。要生成bot令牌,请执行以下步骤:

  • 去医院
  • 单击您已创建的应用程序(如果您没有,请创建一个新的应用程序)
  • 如果一切都已设置,请在左侧“设置”下的菜单上单击
    Bot
  • 如果你看到这个:

    只需单击
    添加Bot

  • 在此页面上,您可以设置化身、用户名并重新生成令牌。单击
    重新生成
    ,然后单击
    复制
    。将令牌粘贴到
    client.login('Paste the copied token here')

  • 运行脚本

  • 享受吧


  • 也许你撤销了它!很多人喜欢撤销按钮,但仍然不知道它的作用

    因此,下次尝试抓取令牌,可能只是为了确保整个代码之间的
    /*
    ,只是为了暂时隐藏它
    */
    用这个普通的例子:

    const Discord=require('Discord.js')
    const client=new Discord.client()
    client.on('ready',()=>{
    console.log('finallyyyyyyy')
    })
    client.login('令牌')
    

    如果它仍然不起作用。那么问题就出在别的地方了。可能是您更改了discord模块文本而忘记了它,或者是某个模块安装了discord.js并对其进行了更改以使其适合他们?尝试单独重新安装discord.js和node.js

    您是否使用您从中获得的令牌更改了
    “令牌”
    ?我已经拥有了bot,这不是我第一次创建它。什么是已撤销的令牌?@c.ales已撤销的令牌是discord由于以下几个原因而无法使用的令牌:不活动、垃圾邮件或恶意行为。只要为你的机器人重新生成一个新的令牌,你就可以开始了。我尝试过创建其他机器人并重新生成令牌,但仍然告诉我,我有一个无效的令牌websocket@c.ales您是否再次尝试重新安装discord.js?还用不同的机器人进行了测试?