Redo responses, Add basic logging.

This commit is contained in:
IDeletedSystem64 2022-07-01 19:34:46 -05:00
parent 4772ab8e0f
commit a2ec5405a2
2 changed files with 34 additions and 23 deletions

View File

@ -5,25 +5,45 @@ module.exports = {
options: [],
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);
},
async parseInteraction (client, config, interaction) {
await interaction.reply(await this.handle(client, config, interaction.user));
await this.handle(client, config, interaction.user, interaction.channel);
},
async handle (client, config, user) {
async handle (client, config, user, channel) {
if (user.id === config.ownerID) {
console.log('Anitrox is restarting now!');
// await message.channel.send('<a:NyabotWorking:697147309531594843> Restarting...');
const embeds = [{
title: '<a:AnitroxWorking:697147309531594843> Restart Bot',
description: 'Restarting Anitrox...',
color: 9442302,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
}
}];
console.log('[SYSTEM] [INFO] Restarting now!');
const response = await channel.send({ embeds });
try {
client.destroy();
await client.login(config.token);
console.log('All systems go');
return '<:NyabotSuccess:697211376740859914> Restart Successful';
console.log('[SYSTEM] [INFO] Restarted successfully!');
await response.edit({
embeds: [{
title: '<a:AnitroxWorking:697147309531594843> Restart Bot',
description: 'Restarted!',
color: 9442302,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
}
}]
});
} catch (e) { console.error(e); }
} else {
return '<:NyabotDenied:697145462565896194> Access Denied, You must be bot owner to execute this command.';
console.error('[SYSTEM] [ERR] User ' + user.username + " tried to restart the bot, but doesn't have permission! If this was you, Check your config.json");
return client.generateErrorMessage('Only the bot owner can restart the bot! Stop.', user.displayAvatarURL());
}
}
};

View File

@ -14,13 +14,13 @@ module.exports = {
process.exit();
},
async handle (_, config, user) {
async handle (client, config, user) {
if (user.id === config.ownerID) {
console.log('The bot is shutting down! Bye bye!');
console.log('[SYSTEM] [INFO] ' + ` The bot is going down for shut down. \nShutdown requested by ${user.username}`);
return {
embeds: [{
title: '<a:AnitroxWorking:697147309531594843> **Shutting Down...**',
description: 'See you next time!',
title: '**Shut down the bot**',
description: '<a:AnitroxWorking:697147309531594843> **Shutting Down...**',
color: 9442302,
footer: {
icon_url: user.displayAvatarURL(),
@ -29,17 +29,8 @@ module.exports = {
}]
};
} else {
return {
embeds: [{
title: '<:AnitroxDenied:809651936642203668> 403 Forbidden',
description: 'You need to be the bot owner to execute this command!',
color: 13632027,
footer: {
icon_url: user.displayAvatarURL(),
text: config.footerTxt
}
}]
};
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());
}
}
};