v5.3.10
fixed current track to not add twice to previousTracks fixed bot disconnection on member move Thanks PR's from original repo!
This commit is contained in:
parent
5d57f6589a
commit
641ef8ee85
3 changed files with 28 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "discord-player-play-dl",
|
"name": "discord-player-play-dl",
|
||||||
"version": "5.3.9",
|
"version": "5.3.10",
|
||||||
"description": "Complete framework to facilitate music commands using discord.js and play-dl",
|
"description": "Complete framework to facilitate music commands using discord.js and play-dl",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|
|
@ -142,6 +142,27 @@ class Player extends EventEmitter<PlayerEvents> {
|
||||||
queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout);
|
queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (queue.connection && oldState.channelId && newState.channelId && oldState.channelId !== newState.channelId && newState.member.id != newState.guild.members.me.id) {
|
||||||
|
if (newState.channelId !== queue.connection.channel.id) {
|
||||||
|
if (!Util.isVoiceEmpty(queue.connection.channel)) return;
|
||||||
|
if (queue._cooldownsTimeout.has(`empty_${oldState.guild.id}`)) return;
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
if (!Util.isVoiceEmpty(queue.connection.channel)) return;
|
||||||
|
if (!this.queues.has(queue.guild.id)) return;
|
||||||
|
if (queue.options.leaveOnEmpty) queue.destroy(true);
|
||||||
|
this.emit("channelEmpty", queue);
|
||||||
|
}, queue.options.leaveOnEmptyCooldown || 0).unref();
|
||||||
|
queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout);
|
||||||
|
} else {
|
||||||
|
const emptyTimeout = queue._cooldownsTimeout.get(`empty_${oldState.guild.id}`);
|
||||||
|
const channelEmpty = Util.isVoiceEmpty(queue.connection.channel);
|
||||||
|
if (!channelEmpty && emptyTimeout) {
|
||||||
|
clearTimeout(emptyTimeout);
|
||||||
|
queue._cooldownsTimeout.delete(`empty_${oldState.guild.id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -192,10 +192,10 @@ class Queue<T = unknown> {
|
||||||
if (this.options.leaveOnEnd) this.destroy();
|
if (this.options.leaveOnEnd) this.destroy();
|
||||||
this.player.emit("queueEnd", this);
|
this.player.emit("queueEnd", this);
|
||||||
} else if (!this.tracks.length && this.repeatMode === QueueRepeatMode.AUTOPLAY) {
|
} else if (!this.tracks.length && this.repeatMode === QueueRepeatMode.AUTOPLAY) {
|
||||||
this._handleAutoplay(Util.last(this.previousTracks));
|
this._handleAutoplay(this.current);
|
||||||
} else {
|
} else {
|
||||||
if (this.repeatMode === QueueRepeatMode.TRACK) return void this.play(Util.last(this.previousTracks), { immediate: true });
|
if (this.repeatMode === QueueRepeatMode.TRACK) return void this.play(this.current, { immediate: true });
|
||||||
if (this.repeatMode === QueueRepeatMode.QUEUE) this.tracks.push(Util.last(this.previousTracks));
|
if (this.repeatMode === QueueRepeatMode.QUEUE) this.tracks.push(this.current);
|
||||||
const nextTrack = this.tracks.shift();
|
const nextTrack = this.tracks.shift();
|
||||||
this.play(nextTrack, { immediate: true });
|
this.play(nextTrack, { immediate: true });
|
||||||
return;
|
return;
|
||||||
|
@ -420,7 +420,7 @@ class Queue<T = unknown> {
|
||||||
*/
|
*/
|
||||||
async back() {
|
async back() {
|
||||||
if (this.#watchDestroyed()) return;
|
if (this.#watchDestroyed()) return;
|
||||||
const prev = this.previousTracks[this.previousTracks.length - 2]; // because last item is the current track
|
const prev = this.previousTracks[this.previousTracks.length - 1];
|
||||||
if (!prev) throw new PlayerError("Could not find previous track", ErrorStatusCode.TRACK_NOT_FOUND);
|
if (!prev) throw new PlayerError("Could not find previous track", ErrorStatusCode.TRACK_NOT_FOUND);
|
||||||
|
|
||||||
return await this.play(prev, { immediate: true });
|
return await this.play(prev, { immediate: true });
|
||||||
|
@ -575,7 +575,7 @@ class Queue<T = unknown> {
|
||||||
if (this.#watchDestroyed()) return;
|
if (this.#watchDestroyed()) return;
|
||||||
const length = typeof options.length === "number" ? (options.length <= 0 || options.length === Infinity ? 15 : options.length) : 15;
|
const length = typeof options.length === "number" ? (options.length <= 0 || options.length === Infinity ? 15 : options.length) : 15;
|
||||||
|
|
||||||
const index = Math.round((this.streamTime / this.current.durationMS) * length);
|
const index = Math.floor((this.streamTime / this.current.durationMS) * length);
|
||||||
const indicator = typeof options.indicator === "string" && options.indicator.length > 0 ? options.indicator : "🔘";
|
const indicator = typeof options.indicator === "string" && options.indicator.length > 0 ? options.indicator : "🔘";
|
||||||
const line = typeof options.line === "string" && options.line.length > 0 ? options.line : "▬";
|
const line = typeof options.line === "string" && options.line.length > 0 ? options.line : "▬";
|
||||||
|
|
||||||
|
@ -622,10 +622,7 @@ class Queue<T = unknown> {
|
||||||
|
|
||||||
this.player.emit("debug", this, "Received play request");
|
this.player.emit("debug", this, "Received play request");
|
||||||
|
|
||||||
if (!options.filtersUpdate) {
|
if (!options.filtersUpdate) this.previousTracks = this.previousTracks.filter((x) => x.id !== track.id);
|
||||||
this.previousTracks = this.previousTracks.filter((x) => x.id !== track.id);
|
|
||||||
this.previousTracks.push(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
let stream = null;
|
let stream = null;
|
||||||
const hasCustomDownloader = typeof this.onBeforeCreateStream === "function";
|
const hasCustomDownloader = typeof this.onBeforeCreateStream === "function";
|
||||||
|
|
Loading…
Reference in a new issue