diff --git a/src/events/loader.ts b/src/events/loader.ts index d84e63b..e379e88 100644 --- a/src/events/loader.ts +++ b/src/events/loader.ts @@ -1,13 +1,24 @@ -import { Player, PlayerEvents, useMainPlayer } from "discord-player"; +import { PlayerEvents, useMainPlayer } from "discord-player"; import { Client } from "discord.js"; import { readdir } from "fs/promises"; /** Load all the events */ -export default async (client: Client) => { +export default async (client: Client, isDev: boolean) => { const events_categories = (await readdir(__dirname)).filter( (element) => !element.endsWith(".js") && !element.endsWith(".ts"), ); + const player = useMainPlayer(); + + if (isDev) { + player.on("debug", async (message) => { + console.log(`General player debug event: ${message}`); + }); + player.events.on("debug", async (_, message) => { + console.log(`Player debug event: ${message}`); + }); + } + events_categories.forEach(async (event_category) => { // Retrieve events const events = await readdir(`${__dirname}/${event_category}`); @@ -29,7 +40,6 @@ export default async (client: Client) => { const event_type = event_type_ext.join("."); if (event_category == "player") { - const player = useMainPlayer() as Player; if (once) { // eslint-disable-next-line return player.events.once(event_type as keyof PlayerEvents, (...args: any[]) => { diff --git a/src/load.ts b/src/load.ts index 8c56413..5f59ec7 100644 --- a/src/load.ts +++ b/src/load.ts @@ -21,7 +21,7 @@ export const run = async (isDev: boolean) => { // Events Discord.JS and Player const events_name = "Events"; - await loadEvents(client) + await loadEvents(client, isDev) .then(() => console.log(logStart(events_name, true))) .catch((err) => { console.error(err);