exports.exec = async (message, bot) => {
await message.channel.send("Rebooting...").catch(err => this.client.console.error(err));
process.exit(1);
};
exports.config = {
aliases: [ ],
enabled: true,
};
exports.help = {
name: 'Restart',
botPermission: '',
userTextPermission: '',
userVoicePermission: '',
usage: 'Restart',
example: [ ]
};
我一点都不知道,我做了很多其他的命令,所有的定义都很好,但是我绝对在为这个苦苦挣扎吗?我完全看不出它是怎么回事。
答案 0 :(得分:0)
exports.exec = async (client, message, args, level) => { // eslint-disable-line no-unused-vars
message.delete();
message.channel.send("Are you sure you want to reboot?\n\nReply with `cancel` to abort the reboot. The reboot will self-abort in 30 seconds");
return message.channel.awaitMessages(m => m.author.id === message.author.id, {
"errors": ["time"],
"max": 1,
time: 30000
}).then(resp => {
if (!resp) return;
resp = resp.array()[0];
const validAnswers = ["yes", "y", "no", "n", "cancel"];
if (validAnswers.includes(resp.content)) {
if (resp.content === "cancel" || resp.content === "no" || resp.content === "n") {
return message.channel.send("Aborting reboot");
} else if (resp.content === "yes" || resp.content === "y") {
client.destroy().then(() => {
process.exit();
}).catch(error => console.error(error));
}
} else {
message.channel.send(`Only \`${validAnswers.join("`, `")}\` are valid, please supply one of those.`).catch(error => console.error(error));
}
}).catch(error => {
console.error(error);
message.channel.send("Reboot timed out");
});
};
/* * * * */
输入 $ restart 时,您会收到来自机器人的自动回复,其中包括
“ Are you sure you want to reboot? Reply with
取消to abort the reboot. The reboot will self-abort in 30 seconds
”
如果您键入“ cancel
”,显然它将取消它;如果您等待超时,它也会被取消。
回复
Yes
| Y
|
将重启机器人
No
| N
|会取消