Redo responses, Add basic logging.
This commit is contained in:
parent
4772ab8e0f
commit
a2ec5405a2
|
@ -5,25 +5,45 @@ 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);
|
||||||
},
|
},
|
||||||
|
|
||||||
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);
|
||||||
},
|
},
|
||||||
|
|
||||||
async handle (client, config, user) {
|
async handle (client, config, user, channel) {
|
||||||
if (user.id === config.ownerID) {
|
if (user.id === config.ownerID) {
|
||||||
console.log('Anitrox is restarting now!');
|
const embeds = [{
|
||||||
// await message.channel.send('<a:NyabotWorking:697147309531594843> Restarting...');
|
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 {
|
try {
|
||||||
client.destroy();
|
client.destroy();
|
||||||
await client.login(config.token);
|
await client.login(config.token);
|
||||||
console.log('All systems go');
|
console.log('[SYSTEM] [INFO] Restarted successfully!');
|
||||||
return '<:NyabotSuccess:697211376740859914> Restart Successful';
|
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); }
|
} catch (e) { console.error(e); }
|
||||||
} else {
|
} 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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,13 +14,13 @@ module.exports = {
|
||||||
process.exit();
|
process.exit();
|
||||||
},
|
},
|
||||||
|
|
||||||
async handle (_, config, user) {
|
async handle (client, config, user) {
|
||||||
if (user.id === config.ownerID) {
|
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 {
|
return {
|
||||||
embeds: [{
|
embeds: [{
|
||||||
title: '<a:AnitroxWorking:697147309531594843> **Shutting Down...**',
|
title: '**Shut down the bot**',
|
||||||
description: 'See you next time!',
|
description: '<a:AnitroxWorking:697147309531594843> **Shutting Down...**',
|
||||||
color: 9442302,
|
color: 9442302,
|
||||||
footer: {
|
footer: {
|
||||||
icon_url: user.displayAvatarURL(),
|
icon_url: user.displayAvatarURL(),
|
||||||
|
@ -29,17 +29,8 @@ module.exports = {
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
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");
|
||||||
embeds: [{
|
return client.generateErrorMessage('Only the bot owner can stop the bot! Stop.', user.displayAvatarURL());
|
||||||
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
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Reference in New Issue