Discord.js重新启动命令不起作用(返回未定义的错误)

时间:2020-10-17 12:32:14

标签: javascript discord discord.js

我正在用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"
};

如果可以,请帮助

1 个答案:

答案 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" }; 将函数作为参数,因此必须将操作包装到函数中。