Node.js 为什么Discord.js锅炉板不能工作?

Node.js 为什么Discord.js锅炉板不能工作?,node.js,discord,discord.js,bots,Node.js,Discord,Discord.js,Bots,我开始编写一个Discord机器人的代码,我使用的是基本的锅炉板代码,这是什么- const Discord = require('discord.js'); const client = new Discord.Client(); client.on('ready', () => { console.log(`Logged in as ${client.user.tag}!`); }); client.on('message', msg => { if (msg.con

我开始编写一个Discord机器人的代码,我使用的是基本的锅炉板代码,这是什么-

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.login('token');
但不幸的是,这不起作用。是的,我用机器人令牌替换了令牌。当我启动它时,它有几秒钟没有响应,然后这个错误会在调试器中弹出。(我正在使用nodemon)


我尝试卸载并重新安装Discord.js,但没有成功。有人能告诉我问题出在哪里吗?

这是一个错误,当web请求被长时间阻塞时,discord.js库中会发生此错误,这可能是由于中断或internet连接不良造成的。可以忽略它,因为它不会终止程序,但您可以尝试将代码放入try/catch语句中以避免它。

请求花费的时间超过指定的
restRequestTimeout
(默认情况下为15秒),并被中止以不锁定请求处理程序。这可能是Discord方面的内部服务器错误,也可能只是连接速度慢。对于后者,可以增加中的
restRequestTimeout
选项,以防止将来的
中止

const client=newdiscord.client({restRequestTimeout:30000});//30岁
(node:14931) UnhandledPromiseRejectionWarning: AbortError: The user aborted a request.
    at RequestHandler.execute (/home/sulphurouscerebrum/Projects/Discord Bot/Sulph Bot/node_modules/discord.js/src/rest/RequestHandler.js:93:15)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:14931) 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(). (rejection id: 3)
(node:14931) [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.
Waiting for the debugger to disconnect...