discord-player-play-dl/src/Queue.js

78 lines
1.9 KiB
JavaScript
Raw Normal View History

const Discord = require('discord.js')
const { EventEmitter } = require('events')
const Track = require('./Track')
2020-01-12 00:01:18 +05:00
/**
* Represents a guild queue.
*/
class Queue extends EventEmitter {
/**
* @param {Discord.Snowflake} guildID ID of the guild this queue is for.
2020-01-12 00:01:18 +05:00
*/
constructor(guildID){
super();
/**
* ID of the guild this queue is for.
* @type {Discord.Snowflake}
2020-01-12 00:01:18 +05:00
*/
this.guildID = guildID;
/**
* The voice connection of this queue.
* @type {Discord.VoiceConnection}
2020-01-12 00:01:18 +05:00
*/
this.voiceConnection = null;
2020-01-12 00:01:18 +05:00
/**
* The tracks of this queue. The first one is currenlty playing and the others are going to be played.
* @type {Track[]}
2020-01-12 00:01:18 +05:00
*/
this.tracks = [];
2020-01-12 00:01:18 +05:00
/**
* Whether the stream is currently stopped.
* @type {boolean}
2020-01-12 00:01:18 +05:00
*/
this.stopped = false;
/**
* Whether the last track was skipped.
* @type {boolean}
2020-01-12 00:01:18 +05:00
*/
this.lastSkipped = false;
2020-01-12 00:01:18 +05:00
/**
* The stream volume of this queue. (0-100)
* @type {number}
2020-01-12 00:01:18 +05:00
*/
this.volume = 100;
/**
* Whether the stream is currently playing.
* @type {boolean}
2020-01-12 00:01:18 +05:00
*/
this.playing = true;
2020-01-18 15:03:22 +05:00
/**
* Whether the repeat mode is enabled.
* @type {boolean}
2020-01-18 15:03:22 +05:00
*/
this.repeatMode = false;
2020-01-12 00:01:18 +05:00
}
};
module.exports = Queue;
2020-01-12 00:01:18 +05:00
/**
* Emitted when the queue is empty.
* @event Queue#end
*/
2020-01-12 22:55:56 +05:00
/**
* Emitted when the voice channel is empty.
* @event Queue#channelEmpty
*/
2020-01-12 00:01:18 +05:00
/**
* Emitted when the track changes.
* @event Queue#trackChanged
* @param {Track} oldTrack The old track (playing before)
* @param {Track} newTrack The new track (currently playing)
2020-01-12 00:01:18 +05:00
* @param {Boolean} skipped Whether the change is due to the skip() function
*/