basic JSDOC
This commit is contained in:
parent
580f4aa9c6
commit
f38e5a8b11
1 changed files with 29 additions and 2 deletions
|
@ -12,25 +12,52 @@ class DiscordPlayer extends EventEmitter<PlayerEvents> {
|
||||||
public readonly queues = new Collection<Snowflake, Queue>();
|
public readonly queues = new Collection<Snowflake, Queue>();
|
||||||
public readonly voiceUtils = new VoiceUtils();
|
public readonly voiceUtils = new VoiceUtils();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new Discord Player
|
||||||
|
* @param {Discord.Client} client The Discord Client
|
||||||
|
*/
|
||||||
constructor(client: Client) {
|
constructor(client: Client) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The discord.js client
|
||||||
|
* @type {Discord.Client}
|
||||||
|
*/
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a queue for a guild if not available, else returns existing queue
|
||||||
|
* @param {Discord.Guild} guild The guild
|
||||||
|
* @param {PlayerOptions} queueInitOptions Queue init options
|
||||||
|
* @returns {Queue}
|
||||||
|
*/
|
||||||
createQueue<T = unknown>(guild: Guild, queueInitOptions?: PlayerOptions & { metadata?: any }) {
|
createQueue<T = unknown>(guild: Guild, queueInitOptions?: PlayerOptions & { metadata?: any }) {
|
||||||
if (this.queues.has(guild.id)) return this.queues.get(guild.id) as Queue<T>;
|
if (this.queues.has(guild.id)) return this.queues.get(guild.id) as Queue<T>;
|
||||||
|
|
||||||
|
const _meta = queueInitOptions.metadata;
|
||||||
|
delete queueInitOptions["metadata"];
|
||||||
const queue = new Queue(this, guild, queueInitOptions);
|
const queue = new Queue(this, guild, queueInitOptions);
|
||||||
if ("metadata" in queueInitOptions) queue.metadata = queueInitOptions.metadata;
|
queue.metadata = _meta;
|
||||||
this.queues.set(guild.id, queue);
|
this.queues.set(guild.id, queue);
|
||||||
|
|
||||||
return queue as Queue<T>;
|
return queue as Queue<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the queue if available
|
||||||
|
* @param {Discord.Snowflake} guild The guild id
|
||||||
|
* @returns {Queue}
|
||||||
|
*/
|
||||||
getQueue<T = unknown>(guild: Snowflake) {
|
getQueue<T = unknown>(guild: Snowflake) {
|
||||||
return this.queues.get(guild) as Queue<T>;
|
return this.queues.get(guild) as Queue<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a queue and returns deleted queue object
|
||||||
|
* @param {Discord.Snowflake} guild The guild id to remove
|
||||||
|
* @returns {Queue}
|
||||||
|
*/
|
||||||
deleteQueue<T = unknown>(guild: Snowflake) {
|
deleteQueue<T = unknown>(guild: Snowflake) {
|
||||||
const prev = this.getQueue<T>(guild);
|
const prev = this.getQueue<T>(guild);
|
||||||
|
|
||||||
|
@ -45,7 +72,7 @@ class DiscordPlayer extends EventEmitter<PlayerEvents> {
|
||||||
/**
|
/**
|
||||||
* Search tracks
|
* Search tracks
|
||||||
* @param {string|Track} query The search query
|
* @param {string|Track} query The search query
|
||||||
* @param {User} requestedBy The person who requested track search
|
* @param {Discord.User} requestedBy The person who requested track search
|
||||||
* @returns {Promise<Track[]>}
|
* @returns {Promise<Track[]>}
|
||||||
*/
|
*/
|
||||||
async search(query: string | Track, requestedBy: User) {
|
async search(query: string | Track, requestedBy: User) {
|
||||||
|
|
Loading…
Reference in a new issue