finally fixed shutdown! can now choose whether or not to shutdown just in case it was a mistake
This commit is contained in:
parent
3fb1334b40
commit
0afb9ad817
1 changed files with 20 additions and 7 deletions
|
@ -1,14 +1,27 @@
|
||||||
exports.run = async (client, message, args, level) => { // eslint-disable-line no-unused-vars
|
exports.run = async (client, message, args, level) => {
|
||||||
const response = await client.awaitReply(message, "**Are you sure you want to shut me down?** Respond with \`yes\` to proceed.")
|
message.delete();
|
||||||
const msg = question;
|
|
||||||
console.log(`Response is ${response}`);
|
let response = await client.awaitReply(message, "**Are you sure you want to shut me down?** Respond with \`yes\` to proceed.");
|
||||||
if(response = "yes") {
|
message.author.lastMessage.delete();
|
||||||
await msg.edit(`Confirmed by ${message.author} Shutting down...`);
|
let msg = client.user.lastMessage;
|
||||||
|
|
||||||
|
if(response === "yes") {
|
||||||
|
await msg.edit(`**Confirmed by ${message.author}.** Shutting down...`);
|
||||||
await Promise.all(client.commands.map(cmd =>
|
await Promise.all(client.commands.map(cmd =>
|
||||||
client.unloadCommand(cmd)
|
client.unloadCommand(cmd)
|
||||||
));
|
));
|
||||||
await msg.edit("Successfully shut down.");
|
await msg.edit(`Successfully shut down by ${message.author}.`);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
} else if(response === "no") {
|
||||||
|
await msg.edit(`**Shutdown cancelled by ${message.author}.** This message will be removed in 5 seconds.`).then(msg => {
|
||||||
|
msg.delete(5000)
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
await msg.edit(`**${message.author} has provided an invalid response**; shutdown aborted. This message will be deleted in 5 seconds.`).then(msg => {
|
||||||
|
msg.delete(5000)
|
||||||
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue