Fix fatal problem where any user can stop the bot

This commit is contained in:
IDeletedSystem64 2022-07-03 18:12:53 -05:00
parent b7f03b872c
commit 8f2c8493bd
1 changed files with 9 additions and 10 deletions

View File

@ -5,32 +5,31 @@ module.exports = {
options: [], options: [],
async parseMessage (client, config, message) { async parseMessage (client, config, message) {
await message.channel.send(await this.handle(client, config, message.author)); await this.handle(client, config, message.author, message.channel);
process.exit();
}, },
async parseInteraction (client, config, interaction) { async parseInteraction (client, config, interaction) {
await interaction.reply(await this.handle(client, config, interaction.user)); await this.handle(client, config, interaction.user, interaction.channel);
process.exit();
}, },
async handle (client, config, user) { async handle (client, config, user, channel) {
if (user.id === config.ownerID) { if (user.id === config.ownerID) {
console.log('[SYSTEM] [INFO] ' + ` The bot is going down for shut down. \nShutdown requested by ${user.username}`); console.log('[SYSTEM] [INFO] ' + `The bot is going down for shut down. \nShutdown requested by ${user.username}`);
return { await channel.send({
embeds: [{ embeds: [{
title: '**Shut down the bot**', title: '**Shut down the bot**',
description: '<a:AnitroxWorking:697147309531594843> **Shutting Down...**', description: ':AnitroxWorking: **Shutting Down...**',
color: 9442302, color: 9442302,
footer: { footer: {
icon_url: user.displayAvatarURL(), icon_url: user.displayAvatarURL(),
text: config.footerTxt text: config.footerTxt
} }
}] }]
}; });
process.exit();
} else { } else {
console.error('[SYSTEM] [ERR] User ' + user.username + " tried to shut down the bot, but doesn't have permission! If this was you, Check your config.json"); console.error('[SYSTEM] [ERR] User ' + user.username + " tried to shut down the bot, but doesn't have permission! If this was you, Check your config.json");
return client.generateErrorMessage('Only the bot owner can stop the bot! Stop.', user.displayAvatarURL()); await channel.send(client.generateErrorMessage('You do not have permission to run this command.', user.displayAvatarURL()));
} }
} }
}; };