我正在用discord.js制作机器人,但我的重启命令不起作用。我不工作是指出现此错误:
(node:41784) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '_timeouts' of undefined
我的代码是:
const config = require('../../config.json');
module.exports.run = async (bot, message, args) => {
if(!config.owners.includes(message.author.id)) {
return message.channel.send(`Only the bot owner can execute this command`)
}
message.channel.send(`Okay, I'll restart...`)
.then(
bot.destroy
).then(
bot.login(config.token)
)
};
module.exports.help = {
name: "restart",
description: "Restarts the bot",
usage: "restart",
category: "dev"
};
如果可以,请帮助
答案 0 :(得分:2)
尝试一下:
@Query(value="select * from ?1 where name=?2",nativeQuery=true)
List method(tablename, name);
const config = require('../../config.json');
module.exports.run = async (bot, message, args) => {
if(!config.owners.includes(message.author.id)) {
return message.channel.send(`Only the bot owner can execute this command`)
}
message.channel.send(`Okay, I'll restart...`)
.then(()=>bot.destroy()) // <<<<
.then(()=>bot.login(config.token)) // <<<<
};
module.exports.help = {
name: "restart",
description: "Restarts the bot",
usage: "restart",
category: "dev"
};
将函数作为参数,因此必须将操作包装到函数中。