javascript - Discord.js 令牌登录问题
问题描述
嗨,即使我重新生成令牌,我的机器人也不会上线。我试图放置一个 catch 块,但没有任何变化。问题是我的电脑吗?脚本?还是我的节点版本(最后一个 LTS 版本)?我希望你有时间回答我!
这是错误:
(node:1976) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided.
at WebSocketConnection.<anonymous> (C:\Users\Atelier34bc\Documents\mpbot\node_modules\discord.js\src\client\ClientManager.js:48:41)
at Object.onceWrapper (events.js:417:26)
at WebSocketConnection.emit (events.js:310:20)
at WebSocketConnection.onClose (C:\Users\Atelier34bc\Documents\mpbot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:390:10)
at WebSocket.onClose (C:\Users\Atelier34bc\Documents\mpbot\node_modules\ws\lib\event-target.js:124:16)
at WebSocket.emit (events.js:310:20)
at WebSocket.emitClose (C:\Users\Atelier34bc\Documents\mpbot\node_modules\ws\lib\websocket.js:191:10)
at TLSSocket.socketOnClose (C:\Users\Atelier34bc\Documents\mpbot\node_modules\ws\lib\websocket.js:850:15)
at TLSSocket.emit (events.js:322:22)
at net.js:672:12
(node:1976) 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: 2)
(node:1976) [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.
这是我的脚本:
const bot = new Discord.Client()
const PREFIX = "$"
const token = 'my_token'
bot.on('ready', () => {
console.log('bot is online')
})
bot.on('message', message => {
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case 'mpall':
if (message.author.id == 655346300958670848) {
const embeds = new Discord.RichEmbed()
.setColor('#FF0000')
.setTitle('Message :')
.setDescription(args.slice(1).join(" "))
message.guild.members.forEach(member =>
member.sendEmbed(embeds))
break;
} else {
var embeds1 = new Discord.RichEmbed()
.setColor('#FF0000')
.setTitle('Acess Denied')
message.channel.send(embeds1)
}
break;
}
})
bot.login(令牌);
解决方案
我用我自己的机器人尝试了代码,它运行良好,你检查过你使用的是机器人令牌而不是客户端 ID 吗?
推荐阅读
- javascript - JS google api翻译srt文件
- c# - 在 C# windows 应用程序中使用动态值切换大小写以进行语音识别
- java - Intellij Idea 插件语法高亮和代码完成在 ${} 中的 Java 字符串中,如 Scala 字符串插值
- python - 访问由 Snakemake 中的函数返回的列表的特定元素
- django - Django CreateView:'str'对象不可调用
- python - 如何使用给定列表中的计数器查找特定键的值
- javascript - JavaScript函数在表单提交上不起作用
- php - 合并和求和多个多维关联数组 PHP
- java - 替换数组中的所有重复项
- node.js - Nuxt - 安装 Sass 时的错误墙