discord-player-play-dl/src/Player.ts

29 lines
851 B
TypeScript
Raw Normal View History

2021-06-11 15:32:22 +05:00
import { Client, Collection, Guild, Snowflake } from "discord.js";
import { TypedEmitter as EventEmitter } from "tiny-typed-emitter";
import { Queue } from "./Structures/Queue";
import { PlayerOptions } from "./types/types";
class DiscordPlayer extends EventEmitter {
public readonly client: Client;
public readonly queues = new Collection<Snowflake, Queue>();
constructor(client: Client) {
super();
this.client = client;
}
createQueue(guild: Guild, queueInitOptions?: PlayerOptions) {
if (this.queues.has(guild.id)) return this.queues.get(guild.id);
const queue = new Queue(this, guild, queueInitOptions);
this.queues.set(guild.id, queue);
return queue;
}
getQueue(guild: Snowflake) {
return this.queues.get(guild);
}
}
export { DiscordPlayer as Player };