如何使命令关闭Discord机器人? (使用Javascript,Node.js和Discord.js)

时间:2020-07-20 19:32:09

标签: javascript discord discord.js

与标题相同。如何创建将关闭Discord Bot的命令?

1 个答案:

答案 0 :(得分:0)

如技巧所建议,您可以使用process.exit(),也可以使用destroy中的方法Client

示例:

client.on("message", message => {
    if (message.content.toLowerCase() == "shutdown") { // Note that this is an example and anyone can use this command.
        message.channel.send("Shutting down...").then(() => {
            client.destroy();
        })
    }
})