【发布时间】:2021-06-30 01:21:13
【问题描述】:
尝试在 discord.js 上重新启动客户端时出错 在这个论坛上找到了这段代码,它在 v12 客户端上似乎可以正常工作,但在我的客户端上它不起作用。
我确实在命令 console.log 之前使用过打印出代码,并且打印出正确。 以及我生成了新令牌,仍然无法正常工作
我想要的是让它通过命令完全重启。 在 v11 上,我的脚本有效,但这个 v12 不再有效。
module.exports.run = async (client, message, args) => {
if(message.author.id != "43437XXXX068625418") return message.channel.send("You're not bot the owner! https://i.imgur.com/8ep8YbI.gif")
try {
message.channel.send("53686XXXX7159040> Attempting a restart...").then(msg => {
//msg.react('????');
setTimeout(function(){
msg.edit("53686XXXX7159040> I should be back up now!");
}, 10000);
})
console.log (config.Settings[0].bot_secret_token);
client.destroy().then(client.login(config.Settings[0].bot_secret_token))
} catch(e) {
message.channel.send(`ERROR: ${e.message}`)
}
}
收到此错误,
(node:9432) UnhandledPromiseRejectionWarning: DiscordjsError: Request to use to
en, but token was unavailable to the client.
at RequestHandler.execute (D:\discordbot2\new\node_modules\discord.js\src\r
st\RequestHandler.js:93:15)
at RequestHandler.execute (D:\discordbot2\new\node_modules\discord.js\src\r
st\RequestHandler.js:97:19)
at RequestHandler.push (D:\discordbot2\new\node_modules\discord.js\src\rest
RequestHandler.js:39:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:9432) 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 termin
te the node process on unhandled promise rejection, use the CLI flag `--unhandl
d-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejecti
ns_mode). (rejection id: 17)
(node:9432) UnhandledPromiseRejectionWarning: DiscordjsError: Request to use to
en, but token was unavailable to the client.
at RequestHandler.execute (D:\discordbot2\new\node_modules\discord.js\src\r
st\RequestHandler.js:93:15)
at RequestHandler.execute (D:\discordbot2\new\node_modules\discord.js\src\r
st\RequestHandler.js:97:19)
at RequestHandler.push (D:\discordbot2\new\node_modules\discord.js\src\rest
RequestHandler.js:39:25)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:9432) 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 termin
te the node process on unhandled promise rejection, use the CLI flag `--unhandl
d-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejecti
ns_mode). (rejection id: 18)
【问题讨论】:
-
message来自哪里? -
Client#destroy() 只需注销机器人并结束与 Discord API 的连接
-
我知道,但它不起作用......根本没有任何反应。
标签: javascript node.js discord.js