diff --git a/package.json b/package.json index 4737441..a990b18 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "discord-player", - "version": "4.0.9", + "version": "4.1.0", "description": "Complete framework to facilitate music commands using discord.js", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -54,7 +54,7 @@ "soundcloud-scraper": "^5.0.0", "spotify-url-info": "^2.2.0", "youtube-sr": "^4.0.7", - "ytdl-core": "^4.7.0" + "ytdl-core": "^4.8.0" }, "devDependencies": { "@babel/cli": "^7.13.16", diff --git a/src/Player.ts b/src/Player.ts index 97837d3..51d657f 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -244,7 +244,8 @@ export class Player extends EventEmitter { author: m.artists[0]?.name ?? 'Unknown Artist', url: m.external_urls?.spotify ?? query, thumbnail: - playlist.images[0]?.url ?? 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + playlist.images[0]?.url ?? + 'https://www.scdn.co/i/_global/twitter_card-default.jpg', duration: Util.buildTimeCode(Util.parseMS(m.duration_ms)), views: 0, requestedBy: message.author, @@ -280,7 +281,9 @@ export class Player extends EventEmitter { description: m.track.description ?? '', author: m.track.artists[0]?.name ?? 'Unknown Artist', url: m.track.external_urls?.spotify ?? query, - thumbnail: m.track.album?.images[0]?.url ?? 'https://www.scdn.co/i/_global/twitter_card-default.jpg', + thumbnail: + m.track.album?.images[0]?.url ?? + 'https://www.scdn.co/i/_global/twitter_card-default.jpg', duration: Util.buildTimeCode(Util.parseMS(m.track.duration_ms)), views: 0, requestedBy: message.author, @@ -326,12 +329,13 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); } else { - const track = tracks.shift(); + const track = tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); + tracks.shift(); this._addTracksToQueue(message, tracks); } @@ -382,12 +386,13 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist); } else { - const track = tracks.shift(); + const track = tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); + tracks[0]; this._addTracksToQueue(message, tracks); } @@ -437,12 +442,13 @@ export class Player extends EventEmitter { const queue = this._addTracksToQueue(message, res.tracks); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res); } else { - const track = res.tracks.shift(); + const track = res.tracks[0]; const queue = (await this._createQueue(message, track).catch( (e) => void this.emit(PlayerEvents.ERROR, e, message) )) as Queue; this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); + res.tracks.shift(); this._addTracksToQueue(message, res.tracks); } @@ -1549,6 +1555,7 @@ export default Player; * The type of Track source, either: * * `soundcloud` - a stream from SoundCloud * * `youtube` - a stream from YouTube + * * `spotify` - a spotify track * * `arbitrary` - arbitrary stream * @typedef {String} TrackSource */ diff --git a/yarn.lock b/yarn.lock index 24d141b..702661d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4642,10 +4642,10 @@ youtube-sr@^4.0.7: "@types/node-fetch" "^2.5.10" node-fetch "^2.6.1" -ytdl-core@^4.7.0: - version "4.7.0" - resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.7.0.tgz#2c92023536484d8a2760d1aa504df2778f87ae21" - integrity sha512-G09HeYsyLMsUCPEuK2asDqmLnOx+n5SxVV3QqGJd+iYuw5Z/qiwx7x0gxZTiAkHBsbG3WuluJWBPswZyrygKmQ== +ytdl-core@^4.8.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.8.0.tgz#d9f037a370a4b984f1f937e7a11b4531e8959443" + integrity sha512-LFhhwqFojReoaME17VpsFeiamygM0W/YNG8O02mrmS2O6Em5LjCPiJYdq7Af3CmJtBEOCdptSZ3Ql+3LGWDGvg== dependencies: m3u8stream "^0.8.3" miniget "^4.0.0"