Skip to content

Commit

Permalink
[feat](logging) better verbose logging
Browse files Browse the repository at this point in the history
  • Loading branch information
0xDevansh committed Mar 15, 2022
1 parent b1bd4e1 commit 5450445
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/core/buttons/loadButtons.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ButtonCommand } from '../../structures/ButtonCommand';
import { Client, Collection } from 'discord.js';
import { logWarning } from '../../utils/logger';
import { logVerbose, logWarning } from '../../utils/logger';

/**
* Loads the buttons provided into client.buttons
Expand All @@ -9,6 +9,7 @@ import { logWarning } from '../../utils/logger';
* @param {ButtonCommand[]} buttons The buttons to load
*/
export const loadButtons = (client: Client, buttons: ButtonCommand[]): void => {
logVerbose('Loading buttons', client);
const buttonCollection = new Collection<string | RegExp, ButtonCommand>();

buttons.forEach((button) => {
Expand All @@ -22,6 +23,7 @@ export const loadButtons = (client: Client, buttons: ButtonCommand[]): void => {
}

buttonCollection.set(button.customId, button);
logVerbose(` ✅ ${button.customId}`, client);
});

client.buttons = buttonCollection;
Expand Down
4 changes: 3 additions & 1 deletion src/core/commands/loadCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const loadCommands = async (client: Client, commands: SlashCommand[]): Pr
commandsCollection.set('global', []);
commandsCollection.set('allGuild', []);

logVerbose('Loading commands', client);
commands.forEach((command) => {
// preload checks
if (command.beforeExecute?.defer && command.beforeExecute?.deferEphemeral)
Expand All @@ -38,9 +39,10 @@ export const loadCommands = async (client: Client, commands: SlashCommand[]): Pr
commandsCollection.get('global')?.push(command);
}

logVerbose(`Loaded command ${command.name}`, client);
logVerbose(` ${command.name}`, client);
});

client.commands = commandsCollection;
logVerbose('Loaded all commands', client);
await syncCommands(client).catch((err) => logError(err, client));
};
4 changes: 3 additions & 1 deletion src/core/selectMenus/loadSelectMenus.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SelectMenuCommand } from '../../structures/SelectMenuCommand';
import { Client, Collection } from 'discord.js';
import { logWarning } from '../../utils/logger';
import { logVerbose, logWarning } from '../../utils/logger';

/**
* Loads the select menus provided into client.selectMenus
Expand All @@ -9,6 +9,7 @@ import { logWarning } from '../../utils/logger';
* @param {SelectMenuCommand[]} selectMenus The SelectMenuCommands to load
*/
export const loadSelectMenus = (client: Client, selectMenus: SelectMenuCommand[]): void => {
logVerbose('Loading select menus', client);
const menuCollection = new Collection<string | RegExp, SelectMenuCommand>();

selectMenus.forEach((menu) => {
Expand All @@ -18,6 +19,7 @@ export const loadSelectMenus = (client: Client, selectMenus: SelectMenuCommand[]
}

menuCollection.set(menu.customId, menu);
logVerbose(` ✅ ${menu.customId}`, client);
});

client.selectMenus = menuCollection;
Expand Down

0 comments on commit 5450445

Please sign in to comment.