diff --git a/commands/restart.js b/commands/restart.js index e21689a..0fd5ea8 100644 --- a/commands/restart.js +++ b/commands/restart.js @@ -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(' Restarting...'); + const embeds = [{ + title: ' 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: ' 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()); } } }; diff --git a/commands/stop.js b/commands/stop.js index 26bad67..a350649 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -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: ' **Shutting Down...**', - description: 'See you next time!', + title: '**Shut down the bot**', + description: ' **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()); } } };