This repository has been archived on 2024-01-30. You can view files and clone it, but cannot push or open issues or pull requests.
anitrox/commands/restart.js

50 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-01-26 14:03:02 -06:00
module.exports = {
name: require('path').parse(__filename).name,
2022-03-29 18:53:55 -05:00
description: 'Restarts the bot',
options: [],
async parseMessage (client, config, message) {
2022-07-01 19:34:46 -05:00
await this.handle(client, config, message.author, message.channel);
},
async parseInteraction (client, config, interaction) {
2022-07-01 19:34:46 -05:00
await this.handle(client, config, interaction.user, interaction.channel);
},
2022-07-01 19:34:46 -05:00
async handle (client, config, user, channel) {
if (user.id === config.ownerID) {
2022-07-01 19:34:46 -05:00
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();
2022-03-29 13:55:44 -05:00
await client.login(config.token);
2022-07-01 19:34:46 -05:00
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 {
2022-07-01 19:34:46 -05:00
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());
}
}
};