我正在遵循指南。我遇到node index.js
了Windows PowerShell,但没有提供预期的输出
它是从discord.js指南中复制并粘贴的。我已经运行了很多次,每次都有相同的确切错误。
// require the discord.js module
const Discord = require('discord.js');
// create a new Discord client
const client = new Discord.Client();
// when the client is ready, run this code
// this event will only trigger one time after logging in
client.once('ready', () => {
console.log('Ready!');
});
// login to Discord with your app's token
client.login('your-token-goes-here');
expected: Ready!
actual:
(node:800) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided.
at WebSocketConnection.client.ws.connection.once.event (C:\Users\mort3\Desktop\Sakabato\node_modules\discord.js\src\client\ClientManager.js:48:41)
at Object.onceWrapper (events.js:276:13)
at WebSocketConnection.emit (events.js:188:13)
at WebSocketConnection.onClose (C:\Users\mort3\Desktop\Sakabato\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:390:10)
at WebSocket.onClose (C:\Users\mort3\Desktop\Sakabato\node_modules\ws\lib\event-target.js:124:16)
at WebSocket.emit (events.js:188:13)
at _receiver.cleanup (C:\Users\mort3\Desktop\Sakabato\node_modules\ws\lib\websocket.js:220:12)
at Receiver.cleanup (C:\Users\mort3\Desktop\Sakabato\node_modules\ws\lib\receiver.js:535:15)
at WebSocket.finalize (C:\Users\mort3\Desktop\Sakabato\node_modules\ws\lib\websocket.js:206:20)
at TLSSocket.emit (events.js:193:15)
(node:800) 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:800) [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.
discord API和discord.js(这是discord api的包装器)需要身份验证令牌。您在登录时提供此令牌:
client.login(<insert your token here>)
您并没有用your-token-goes-here
实际的身份验证令牌替换填充文本,该身份验证令牌是通过在不协调的情况下制作应用程序而收到的(请参阅https://discordjs.guide/#/preparations/setting-up-a-bot-application)
要查看我如何到达这里,请查看堆栈跟踪以及错误消息:
Error: Incorrect login details were provided.
这是什么错,这是不言而喻的。在这种情况下,您没有提供任何登录详细信息。