2020-06-02 16:11:12 +05:00
|
|
|
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 {
|
|
|
|
|
|
|
|
/**
|
2020-06-02 16:11:12 +05:00
|
|
|
* @param {Discord.Snowflake} guildID ID of the guild this queue is for.
|
2020-01-12 00:01:18 +05:00
|
|
|
*/
|
|
|
|
constructor(guildID){
|
|
|
|
super();
|
|
|
|
/**
|
2020-06-02 16:11:12 +05:00
|
|
|
* ID of the guild this queue is for.
|
|
|
|
* @type {Discord.Snowflake}
|
2020-01-12 00:01:18 +05:00
|
|
|
*/
|
|
|
|
this.guildID = guildID;
|
|
|
|
/**
|
2020-06-02 16:11:12 +05:00
|
|
|
* The voice connection of this queue.
|
|
|
|
* @type {Discord.VoiceConnection}
|
2020-01-12 00:01:18 +05:00
|
|
|
*/
|
2020-06-02 16:11:12 +05:00
|
|
|
this.voiceConnection = null;
|
2020-01-12 00:01:18 +05:00
|
|
|
/**
|
2020-06-02 16:11:12 +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
|
|
|
*/
|
2020-06-02 16:11:12 +05:00
|
|
|
this.tracks = [];
|
2020-01-12 00:01:18 +05:00
|
|
|
/**
|
|
|
|
* Whether the stream is currently stopped.
|
2020-06-02 16:11:12 +05:00
|
|
|
* @type {boolean}
|
2020-01-12 00:01:18 +05:00
|
|
|
*/
|
|
|
|
this.stopped = false;
|
|
|
|
/**
|
2020-06-02 16:11:12 +05:00
|
|
|
* Whether the last track was skipped.
|
|
|
|
* @type {boolean}
|
2020-01-12 00:01:18 +05:00
|
|
|
*/
|
2020-06-02 16:11:12 +05:00
|
|
|
this.lastSkipped = false;
|
2020-01-12 00:01:18 +05:00
|
|
|
/**
|
2020-06-02 16:11:12 +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.
|
2020-06-02 16:11:12 +05:00
|
|
|
* @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.
|
2020-06-02 16:11:12 +05:00
|
|
|
* @type {boolean}
|
2020-01-18 15:03:22 +05:00
|
|
|
*/
|
|
|
|
this.repeatMode = false;
|
2020-01-12 00:01:18 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-06-02 16:11:12 +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
|
|
|
/**
|
2020-06-02 16:11:12 +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
|
|
|
|
*/
|