【发布时间】:2020-03-07 11:54:14
【问题描述】:
我在这里遇到了一个非常奇怪的错误......
今天我想建立一个新的机器人项目,但我遇到了很多麻烦!
在 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 令牌。好吧,也许它改变了什么。问题是,它没有改变。事实上,该令牌似乎仍然有效,并且可以让我的一个旧机器人工作!
此时我已经尝试了所有方法。我也尝试按照它给我的链接,但无济于事,它仍然“崩溃”。
有什么建议吗?
【问题讨论】:
-
我的项目因此而停止,任何帮助将不胜感激!谢谢:)
-
确保您使用的是实际的机器人令牌,而不是来自开发者门户的客户端 ID 或客户端密码。
-
@Tarazed 我正在使用客户端 ID...不过,在我的旧项目中,使用客户端 ID 就可以了!
-
如果是这种情况,我会感到惊讶,客户端 ID 不应该工作。您需要在门户上的应用程序中创建一个机器人,然后使用它的令牌。
-
@Tarazed 问 .gg/apandah 上的人,我确实设法使用 API 创建了一个 selfbot..
标签: node.js discord.js