Merge pull request #428 from Androz2091/develop

v4.1.0
This commit is contained in:
MegaPixel 2021-05-14 06:22:27 +05:45 committed by GitHub
commit 3430a2f87f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 11 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "discord-player", "name": "discord-player",
"version": "4.0.9", "version": "4.1.0",
"description": "Complete framework to facilitate music commands using discord.js", "description": "Complete framework to facilitate music commands using discord.js",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index.d.ts", "types": "lib/index.d.ts",
@ -54,7 +54,7 @@
"soundcloud-scraper": "^5.0.0", "soundcloud-scraper": "^5.0.0",
"spotify-url-info": "^2.2.0", "spotify-url-info": "^2.2.0",
"youtube-sr": "^4.0.7", "youtube-sr": "^4.0.7",
"ytdl-core": "^4.7.0" "ytdl-core": "^4.8.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.13.16", "@babel/cli": "^7.13.16",

View file

@ -244,7 +244,8 @@ export class Player extends EventEmitter {
author: m.artists[0]?.name ?? 'Unknown Artist', author: m.artists[0]?.name ?? 'Unknown Artist',
url: m.external_urls?.spotify ?? query, url: m.external_urls?.spotify ?? query,
thumbnail: 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)), duration: Util.buildTimeCode(Util.parseMS(m.duration_ms)),
views: 0, views: 0,
requestedBy: message.author, requestedBy: message.author,
@ -280,7 +281,9 @@ export class Player extends EventEmitter {
description: m.track.description ?? '', description: m.track.description ?? '',
author: m.track.artists[0]?.name ?? 'Unknown Artist', author: m.track.artists[0]?.name ?? 'Unknown Artist',
url: m.track.external_urls?.spotify ?? query, 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)), duration: Util.buildTimeCode(Util.parseMS(m.track.duration_ms)),
views: 0, views: 0,
requestedBy: message.author, requestedBy: message.author,
@ -326,12 +329,13 @@ export class Player extends EventEmitter {
const queue = this._addTracksToQueue(message, tracks); const queue = this._addTracksToQueue(message, tracks);
this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl);
} else { } else {
const track = tracks.shift(); const track = tracks[0];
const queue = (await this._createQueue(message, track).catch( const queue = (await this._createQueue(message, track).catch(
(e) => void this.emit(PlayerEvents.ERROR, e, message) (e) => void this.emit(PlayerEvents.ERROR, e, message)
)) as Queue; )) as Queue;
this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, pl);
this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue);
tracks.shift();
this._addTracksToQueue(message, tracks); this._addTracksToQueue(message, tracks);
} }
@ -382,12 +386,13 @@ export class Player extends EventEmitter {
const queue = this._addTracksToQueue(message, tracks); const queue = this._addTracksToQueue(message, tracks);
this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist);
} else { } else {
const track = tracks.shift(); const track = tracks[0];
const queue = (await this._createQueue(message, track).catch( const queue = (await this._createQueue(message, track).catch(
(e) => void this.emit(PlayerEvents.ERROR, e, message) (e) => void this.emit(PlayerEvents.ERROR, e, message)
)) as Queue; )) as Queue;
this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, playlist);
this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue);
tracks[0];
this._addTracksToQueue(message, tracks); this._addTracksToQueue(message, tracks);
} }
@ -437,12 +442,13 @@ export class Player extends EventEmitter {
const queue = this._addTracksToQueue(message, res.tracks); const queue = this._addTracksToQueue(message, res.tracks);
this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res);
} else { } else {
const track = res.tracks.shift(); const track = res.tracks[0];
const queue = (await this._createQueue(message, track).catch( const queue = (await this._createQueue(message, track).catch(
(e) => void this.emit(PlayerEvents.ERROR, e, message) (e) => void this.emit(PlayerEvents.ERROR, e, message)
)) as Queue; )) as Queue;
this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res); this.emit(PlayerEvents.PLAYLIST_ADD, message, queue, res);
this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue); this.emit(PlayerEvents.TRACK_START, message, queue.tracks[0], queue);
res.tracks.shift();
this._addTracksToQueue(message, res.tracks); this._addTracksToQueue(message, res.tracks);
} }
@ -1549,6 +1555,7 @@ export default Player;
* The type of Track source, either: * The type of Track source, either:
* * `soundcloud` - a stream from SoundCloud * * `soundcloud` - a stream from SoundCloud
* * `youtube` - a stream from YouTube * * `youtube` - a stream from YouTube
* * `spotify` - a spotify track
* * `arbitrary` - arbitrary stream * * `arbitrary` - arbitrary stream
* @typedef {String} TrackSource * @typedef {String} TrackSource
*/ */

View file

@ -4642,10 +4642,10 @@ youtube-sr@^4.0.7:
"@types/node-fetch" "^2.5.10" "@types/node-fetch" "^2.5.10"
node-fetch "^2.6.1" node-fetch "^2.6.1"
ytdl-core@^4.7.0: ytdl-core@^4.8.0:
version "4.7.0" version "4.8.0"
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.7.0.tgz#2c92023536484d8a2760d1aa504df2778f87ae21" resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.8.0.tgz#d9f037a370a4b984f1f937e7a11b4531e8959443"
integrity sha512-G09HeYsyLMsUCPEuK2asDqmLnOx+n5SxVV3QqGJd+iYuw5Z/qiwx7x0gxZTiAkHBsbG3WuluJWBPswZyrygKmQ== integrity sha512-LFhhwqFojReoaME17VpsFeiamygM0W/YNG8O02mrmS2O6Em5LjCPiJYdq7Af3CmJtBEOCdptSZ3Ql+3LGWDGvg==
dependencies: dependencies:
m3u8stream "^0.8.3" m3u8stream "^0.8.3"
miniget "^4.0.0" miniget "^4.0.0"