From 0327e8069f7921646abfe4d5b33ee5b350d21616 Mon Sep 17 00:00:00 2001 From: Slincnik Date: Thu, 16 Jan 2025 17:27:23 +0300 Subject: [PATCH] feat: added support discord-player and him events --- src/handlers/event-handler/index.ts | 14 ++++++++++---- src/structures/client.ts | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/handlers/event-handler/index.ts b/src/handlers/event-handler/index.ts index 397f0e6a..a3980c8a 100644 --- a/src/handlers/event-handler/index.ts +++ b/src/handlers/event-handler/index.ts @@ -63,9 +63,15 @@ export class EventHandler { } $registerEvents() { - for (const { data, run } of this.events) { - if (data.once) this.client.once(data.name, (...args) => run(...args)); - else this.client.on(data.name, (...args) => run(...args)); - } + const player = useMainPlayer(); + this.events.forEach(event => { + if (event.data.player) { + player.events.on(event.data.name as keyof GuildQueueEvents, event.run); + } else if (event.data.once) { + this.client.once(event.data.name, event.run); + } else { + this.client.on(event.data.name, event.run); + } + }); } } diff --git a/src/structures/client.ts b/src/structures/client.ts index 6fef258b..e9eef352 100644 --- a/src/structures/client.ts +++ b/src/structures/client.ts @@ -7,6 +7,7 @@ import ConfigService from "@/services/config/index.js"; import InternationalizationService from "@/services/languages/index.js"; import { SUPER_CONTEXT } from "@/constants/index.js"; import { cacheRemindsData } from "@/types.js"; +import { Player } from "discord-player"; export class ExtendedClient extends Client { configService = new ConfigService(); @@ -29,6 +30,9 @@ export class ExtendedClient extends Client { super(options); new Handlers(this); + + // @ts-ignore - because ExtendedClient != Client from discord.js + new Player(this); SUPER_CONTEXT.enterWith(this); }