2021-04-06 17:58:46 +05:00
|
|
|
import { EventEmitter } from 'events';
|
2021-05-01 13:28:24 +05:00
|
|
|
import { Client, Collection, Snowflake, Message } from 'discord.js';
|
2021-04-06 17:58:46 +05:00
|
|
|
import Util from './utils/Util';
|
2021-05-01 13:28:24 +05:00
|
|
|
import Queue from './Structures/Queue';
|
|
|
|
import { ExtractorModel } from './Structures/ExtractorModel';
|
2021-04-04 22:36:40 +05:00
|
|
|
|
2021-04-06 20:38:17 +05:00
|
|
|
export class Player extends EventEmitter {
|
2021-04-21 12:09:16 +05:00
|
|
|
public client: Client;
|
2021-05-01 13:28:24 +05:00
|
|
|
public queues = new Collection<Snowflake, Queue>();
|
|
|
|
public Extractors = new Collection<string, ExtractorModel>();
|
2021-04-09 17:59:14 +05:00
|
|
|
|
2021-05-01 13:05:12 +05:00
|
|
|
constructor(client: Client) {
|
2021-04-04 22:36:40 +05:00
|
|
|
super();
|
|
|
|
|
2021-04-06 17:58:46 +05:00
|
|
|
Object.defineProperty(this, 'client', {
|
2021-04-04 22:36:40 +05:00
|
|
|
value: client,
|
|
|
|
enumerable: false
|
|
|
|
});
|
|
|
|
|
2021-05-01 13:28:24 +05:00
|
|
|
Util.alertFFmpeg();
|
|
|
|
}
|
|
|
|
|
|
|
|
public createQueue(message: Message) {
|
|
|
|
if (this.queues.has(message.guild.id)) return this.queues.get(message.guild.id);
|
|
|
|
|
|
|
|
const queue = new Queue(this, message);
|
|
|
|
void this.queues.set(message.guild.id, queue);
|
|
|
|
return queue;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getQueue(message: Message) {
|
|
|
|
return this.queues.get(message.guild.id) ?? null;
|
2021-04-23 23:27:51 +05:00
|
|
|
}
|
|
|
|
|
2021-05-01 12:59:42 +05:00
|
|
|
|
2021-04-04 22:44:45 +05:00
|
|
|
}
|
2021-04-06 20:38:17 +05:00
|
|
|
|
2021-05-01 13:05:12 +05:00
|
|
|
export default Player;
|