mirror of
https://github.com/JonnyBro/JaBa.git
synced 2025-01-19 17:03:47 +05:00
feat: added support discord-player and him events
This commit is contained in:
parent
cd5d1f2e66
commit
0327e8069f
2 changed files with 14 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue