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() {
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);
}
});
}
}

View file

@ -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<true> {
configService = new ConfigService();
@ -29,6 +30,9 @@ export class ExtendedClient extends Client<true> {
super(options);
new Handlers(this);
// @ts-ignore - because ExtendedClient != Client<boolean> from discord.js
new Player(this);
SUPER_CONTEXT.enterWith(this);
}