【发布时间】:2019-11-05 23:18:13
【问题描述】:
我正在尝试为服务器制作 Discord 机器人,我在终端中输入“node .”来运行机器人,但出现此错误:
(node:17632) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided.
at WebSocketConnection.<anonymous> (C:\Users\Thela\code\node_modules\discord.js\src\client\ClientManager.js:48:41)
at Object.onceWrapper (events.js:300:26)
at WebSocketConnection.emit (events.js:210:5)
at WebSocketConnection.onClose (C:\Users\Thela\code\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:390:10)
at WebSocket.onClose (C:\Users\Thela\code\node_modules\ws\lib\event-target.js:124:16)
at WebSocket.emit (events.js:210:5)
at WebSocket.emitClose (C:\Users\Thela\code\node_modules\ws\lib\websocket.js:191:10)
at TLSSocket.socketOnClose (C:\Users\Thela\code\node_modules\ws\lib\websocket.js:850:15)
at TLSSocket.emit (events.js:215:7)
at net.js:658:12
(node:17632) 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: 2)
(node:17632) [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.
在终端中。 这是 index.js 文件:
const Discord = require('discord.js');
const config = require('./config.json');
const client = new Discord.Client();
client.once('ready', () => {
console.log('Ready!');
});
client.on('message', message => {
if (message.content === '!ping') {
message.channel.send('Pong.');
}
});
client.login(config.token);
这是 config.json:
{
"prefix": "!",
"token": "7F2x4ct0AMuBeJKZUGmtIz_RZVKve-N4"
}
我意识到我没有输入完整的错误 哎呀
【问题讨论】:
-
在此处发布令牌是否安全...?
-
真正的错误是
Error: Incorrect login details were provided.。Promise部分是另一个问题。 -
@appleapple 这不是另一个错误,看起来是登录承诺没有得到处理,女巫是首先导致错误的原因。
-
@ThomasReichmann 承诺拒绝不是真正的错误,这里的问题是承诺不应该首先被拒绝。
标签: javascript node.js discord discord.js