feat: added support discord player with events

This commit is contained in:
Slincnik 2024-12-14 18:44:26 +03:00
parent f3d85c3ec2
commit a3c7d1fef6
No known key found for this signature in database
2 changed files with 5 additions and 0 deletions

View file

@ -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);
}

View file

@ -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);
}