From a3c7d1fef64a3abbdf8316ea57af7ce4a30af735 Mon Sep 17 00:00:00 2001 From: Slincnik Date: Sat, 14 Dec 2024 18:44:26 +0300 Subject: [PATCH] feat: added support discord player with events --- src/handlers/event-handler/index.js | 3 +++ src/structures/client.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/handlers/event-handler/index.js b/src/handlers/event-handler/index.js index c63d2dc7..0144bbba 100644 --- a/src/handlers/event-handler/index.js +++ b/src/handlers/event-handler/index.js @@ -3,6 +3,7 @@ import logger from "../../helpers/logger.js"; import useClient from "../../utils/use-client.js"; import { getFilePaths } from "../../utils/index.js"; import { toFileURL } from "../../utils/resolve-file.js"; +import { useMainPlayer } from "discord-player"; export const events = []; @@ -39,7 +40,9 @@ const buildEvents = async () => { const registerEvents = async () => { const client = useClient(); + const player = useMainPlayer(); for (const { data, run } of events) { + if (data.player) player.events.on(data.name, run); if (data.once) client.once(data.name, run); else client.on(data.name, run); } diff --git a/src/structures/client.js b/src/structures/client.js index a25c9f47..b875e1d7 100644 --- a/src/structures/client.js +++ b/src/structures/client.js @@ -1,4 +1,5 @@ import { Client } from "discord.js"; +import { Player } from "discord-player"; import MongooseAdapter from "../adapters/database/MongooseAdapter.js"; import { init as initCommands } from "../handlers/command-handler/index.js"; import { init as initEvents } from "../handlers/event-handler/index.js"; @@ -20,6 +21,7 @@ export class ExtendedClient extends Client { this.configService = new ConfigService(); this.adapter = new MongooseAdapter(this.configService.get("mongoDB")); this.i18n = new InternationalizationService(this); + new Player(this); SUPER_CONTEXT.enterWith(this); }