feat: added support discord-player and him events

This commit is contained in:
Slincnik 2025-01-16 17:27:23 +03:00
parent cd5d1f2e66
commit 0327e8069f
No known key found for this signature in database
2 changed files with 14 additions and 4 deletions

View file

@ -63,9 +63,15 @@ export class EventHandler {
} }
$registerEvents() { $registerEvents() {
for (const { data, run } of this.events) { const player = useMainPlayer();
if (data.once) this.client.once(data.name, (...args) => run(...args)); this.events.forEach(event => {
else this.client.on(data.name, (...args) => run(...args)); 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);
}
});
} }
} }

View file

@ -7,6 +7,7 @@ import ConfigService from "@/services/config/index.js";
import InternationalizationService from "@/services/languages/index.js"; import InternationalizationService from "@/services/languages/index.js";
import { SUPER_CONTEXT } from "@/constants/index.js"; import { SUPER_CONTEXT } from "@/constants/index.js";
import { cacheRemindsData } from "@/types.js"; import { cacheRemindsData } from "@/types.js";
import { Player } from "discord-player";
export class ExtendedClient extends Client<true> { export class ExtendedClient extends Client<true> {
configService = new ConfigService(); configService = new ConfigService();
@ -29,6 +30,9 @@ export class ExtendedClient extends Client<true> {
super(options); super(options);
new Handlers(this); new Handlers(this);
// @ts-ignore - because ExtendedClient != Client<boolean> from discord.js
new Player(this);
SUPER_CONTEXT.enterWith(this); SUPER_CONTEXT.enterWith(this);
} }