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.8 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 === process.env.OWNERID) {
2022-07-01 19:34:46 -05:00
const embeds = [{
title: '<a:AnitroxWorking:997565411212144730> Restart Bot',
2022-12-26 16:28:19 -06:00
description: '<a:AnitroxWorking:997565411212144730> Restarting now, Be back in a minute!',
2022-07-01 19:34:46 -05:00
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(process.env.TOKEN);
2022-07-01 19:34:46 -05:00
console.log('[SYSTEM] [INFO] Restarted successfully!');
await response.edit({
embeds: [{
title: ':white_check_mark: Restart Bot',
2022-07-01 19:34:46 -05:00
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");
await channel.send(client.generateErrorMessage('You do not have permission to run this command.', user.displayAvatarURL()));
}
}
};