mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-12-28 22:33:02 +05:00
feat: added support discord player with events
This commit is contained in:
parent
f3d85c3ec2
commit
a3c7d1fef6
2 changed files with 5 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue