mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-03 14:38:49 +00:00
fix: updated logging for commands
This commit is contained in:
1 parent
5c8f3353f9
commit
a04d0aeb5b
24 files changed
+510
-292
No files matched your search
@@ -1,4 +1,3 @@
|
||||
const logger = require('../../services/logger');
|
||||
const config = require('config');
|
||||
const embedOptions = config.get('embedOptions');
|
||||
const { notValidGuildId } = require('../../utils/validation/systemCommandValidator');
|
||||
@@ -14,21 +13,46 @@ module.exports = {
|
||||
.setDMPermission(false)
|
||||
.setNSFW(false),
|
||||
execute: async ({ interaction, client, executionId }) => {
|
||||
const logger = require('../../services/logger').child({
|
||||
source: 'reload.js',
|
||||
module: 'slashCommand',
|
||||
name: '/reload',
|
||||
executionId: executionId,
|
||||
shardId: interaction.guild.shardId,
|
||||
guildId: interaction.guild.id
|
||||
});
|
||||
|
||||
if (await notValidGuildId({ interaction, executionId })) {
|
||||
logger.debug('Not a valid guild id.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
logger.info('Reloading commands across all shards.');
|
||||
logger.info(`Execution ID: ${executionId}`);
|
||||
await client.shard
|
||||
.broadcastEval((shardClient) => {
|
||||
shardClient.registerClientCommands(shardClient);
|
||||
})
|
||||
.broadcastEval(
|
||||
async (shardClient, { executionId }) => {
|
||||
shardClient.registerClientCommands({ client: shardClient, executionId });
|
||||
},
|
||||
{ context: { executionId: executionId } }
|
||||
)
|
||||
.then(() => {
|
||||
logger.info('Reloaded commands across all shards.');
|
||||
logger.info('Successfully reloaded commands across all shards.');
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(error, 'Failed to reload commands.');
|
||||
logger.error(error, 'Failed to reload commands across shards.');
|
||||
|
||||
logger.debug('Responding with error embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [
|
||||
new EmbedBuilder()
|
||||
|
||||
.setDescription(
|
||||
`**${embedOptions.icons.error} Oops!**\n_Hmm.._ It seems I am unable to reload commands across shards.`
|
||||
)
|
||||
.setColor(embedOptions.colors.error)
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
const commands = client.commands.map((command) => {
|
||||
@@ -38,6 +62,7 @@ module.exports = {
|
||||
|
||||
let embedDescription = `**${embedOptions.icons.bot} Reloaded commands**\n` + commands.join('\n');
|
||||
|
||||
logger.debug('Responding with success embed.');
|
||||
return await interaction.editReply({
|
||||
embeds: [new EmbedBuilder().setDescription(embedDescription).setColor(embedOptions.colors.success)]
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user