我这里有一个很奇怪的错误...
今天我想建立一个新的机器人项目,但是我遇到了很多麻烦!
在Ubuntu 18.04下运行是否有任何区别。这正是我所做的:
npm init #I follow the steps and all
npm install discord.js
npm install nodemon
touch index.js
#I start the bot
nodemon index.js
从那里,基本上我会得到一个错误,告诉我index.js为空。因此,我在其中添加了以下代码:
const discord = require("discord.js"); //import discord
var client = new discord.Client();
//console.log(client.emojis.find(emoji => emoji.name === "pkachu").id);
client.on('ready', () => {
console.log("ready to kick ass");
});
client.login('VALID discord token thing');
可悲的是,我会遇到以下错误:
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
(node:9771) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at WebSocketManager.connect (/home/lolcat/Documents/goodbot/node_modules/discord.js/src/client/websocket/WebSocketManager.js:135:26)
at Client.login (/home/lolcat/Documents/goodbot/node_modules/discord.js/src/client/Client.js:220:21)
(node:9771) 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:9771) [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.
[nodemon] clean exit - waiting for changes before restart
好的,这件事告诉我它具有无效的discord.js令牌。好吧,也许它改变了。事情是,它没有改变。实际上,该令牌似乎仍然有效,可以使我的一个较早的机器人正常工作!
我现在已经尝试了一切。我也尝试遵循它给我的链接,但无济于事,它仍然“崩溃”。
有什么提示吗?