Skip to content

Commit

Permalink
Merge pull request #397 from Androz2091/develop
Browse files Browse the repository at this point in the history
⚡ v4.0.6
  • Loading branch information
MegaPixel authored May 8, 2021
2 parents 10bc0d2 + cdd182f commit cf89dbe
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Steps to reproduce the behavior:

**Please complete the following information:**
- Node Version: [x.x.x]
- Library Version: [x.x.x]
- Discord Player Version: [x.x.x]
- Discord.js Version: [x.x.x]

**Additional context**
Expand Down
12 changes: 12 additions & 0 deletions docs/faq/custom_filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# How to add custom audio filters

Audio filters in **Discord Player** are **[FFmpeg audio filters](http://ffmpeg.org/ffmpeg-all.html#Audio-Filters)**. You can add your own audio filter like this:

```js
const { AudioFilters } = require("discord-player");

AudioFilters.define("3D", "apulsator=hz=0.128");

// later, it can be used like this
player.setFilters(message, { "3D": true });
```
11 changes: 11 additions & 0 deletions docs/faq/live_video.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# How to play live videos

You cannot play live videos by default. If you need to play the live video, just add this option:

```js
const player = new Player(client, {
enableLive: true // enables livestream
});
```

However, you cannot use audio filters with livestreams using this library!
15 changes: 15 additions & 0 deletions docs/faq/pause_resume.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Pause and Resume is not working properly

This is a bug in **[discord.js#5300](https://github.com/discordjs/discord.js/issues/5300)**.

# Fix

You have to update your command something like this:

```diff
- client.player.resume(message);

+ client.player.resume(message);
+ client.player.pause(message);
+ client.player.resume(message);
```
8 changes: 8 additions & 0 deletions docs/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
files:
- name: Extractors API
path: extractor.md
- name: FAQ
files:
- name: Custom Filters
path: custom_filters.md
- name: Livestreams
path: live_video.md
- name: Pause & Resume
path: pause_resume.md
- name: YouTube
files:
- name: Using Cookies
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-player",
"version": "4.0.5",
"version": "4.0.6",
"description": "Complete framework to facilitate music commands using discord.js",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -50,11 +50,11 @@
},
"homepage": "https://github.com/Androz2091/discord-player#readme",
"dependencies": {
"discord-ytdl-core": "^5.0.2",
"discord-ytdl-core": "^5.0.3",
"soundcloud-scraper": "^4.0.3",
"spotify-url-info": "^2.2.0",
"youtube-sr": "^4.0.4",
"ytdl-core": "^4.5.0"
"youtube-sr": "^4.0.6",
"ytdl-core": "^4.7.0"
},
"devDependencies": {
"@babel/cli": "^7.13.16",
Expand Down
15 changes: 10 additions & 5 deletions src/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ export class Player extends EventEmitter {
*/
this.filters = AudioFilters;

this.client.on('voiceStateUpdate', (o, n) => void this._handleVoiceStateUpdate(o, n));
this.client.on('voiceStateUpdate', this._handleVoiceStateUpdate.bind(this));

// auto detect @discord-player/extractor
if (!this.options.disableAutoRegister) {
let nv: any;

// tslint:disable:no-conditional-assignment
if ((nv = Util.require('@discord-player/extractor'))) {
['Attachment', 'Facebook', 'Reverbnation', 'Vimeo'].forEach((ext) => void this.use(ext, nv[ext]));
}
Expand Down Expand Up @@ -269,6 +271,7 @@ export class Player extends EventEmitter {
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);
this._addTracksToQueue(message, tracks);
}
Expand Down Expand Up @@ -323,6 +326,7 @@ export class Player extends EventEmitter {
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);
this._addTracksToQueue(message, res.tracks);
}
Expand Down Expand Up @@ -820,9 +824,9 @@ export class Player extends EventEmitter {
queue.tracks = queue.tracks.filter((t) => t !== trackFound);
}
} else {
trackFound = queue.tracks.find((s) => s === track);
trackFound = queue.tracks.find((s) => s.url === track.url);
if (trackFound) {
queue.tracks = queue.tracks.filter((s) => s !== trackFound);
queue.tracks = queue.tracks.filter((s) => s.url !== trackFound.url);
}
}

Expand Down Expand Up @@ -879,8 +883,9 @@ export class Player extends EventEmitter {
: 15;

const index = Math.round((currentStreamTime / totalTime) * length);
const indicator = '🔘';
const line = '▬';
const indicator =
typeof options?.indicator === 'string' && options?.indicator.length > 0 ? options?.indicator : '🔘';
const line = typeof options?.line === 'string' && options?.line.length > 0 ? options?.line : '▬';

if (index >= 1 && index <= length) {
const bar = line.repeat(length - 1).split('');
Expand Down
2 changes: 2 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export interface PlayerProgressbarOptions {
timecodes?: boolean;
queue?: boolean;
length?: number;
line?: string;
indicator?: string;
}

export interface LyricsData {
Expand Down
8 changes: 6 additions & 2 deletions src/utils/AudioFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ const FilterList = {
},

get names() {
return Object.keys(this).filter((p) => !['names', 'length'].includes(p) && typeof this[p as FiltersName] !== 'function');
return Object.keys(this).filter(
(p) => !['names', 'length'].includes(p) && typeof this[p as FiltersName] !== 'function'
);
},

get length() {
return Object.keys(this).filter((p) => !['names', 'length'].includes(p) && typeof this[p as FiltersName] !== 'function').length;
return Object.keys(this).filter(
(p) => !['names', 'length'].includes(p) && typeof this[p as FiltersName] !== 'function'
).length;
},

toString() {
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1785,12 +1785,12 @@ diff@^4.0.1:
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==

discord-ytdl-core@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/discord-ytdl-core/-/discord-ytdl-core-5.0.2.tgz#28fb8712af8b5fda34f20800d2226b556e700422"
integrity sha512-tuu+skr0cA89Li7sCH+L1p3TwdfSOunmC9BFzSa0Jj567B1F2leVVbjKQ5ZKpsW1cXKv0fh0PdQA2/Fnu6WcQA==
discord-ytdl-core@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/discord-ytdl-core/-/discord-ytdl-core-5.0.3.tgz#a31560f0bede41d6fc969377083ae958deac2b72"
integrity sha512-q4GOEFiV19l0OcPezXnkDWualf+n96LcbTEWReceiDHdx4xxn5CXZX9PR4iDTXQR3Kv2VUkwB8RO8dI50d88vQ==
dependencies:
prism-media "^1.2.7"
prism-media "^1.2.9"

discord.js-docgen@discordjs/docgen#ts-patch:
version "0.9.0"
Expand Down Expand Up @@ -3476,7 +3476,7 @@ prettier@^2.2.1:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==

prism-media@^1.2.7, prism-media@^1.2.9:
prism-media@^1.2.9:
version "1.2.9"
resolved "https://registry.yarnpkg.com/prism-media/-/prism-media-1.2.9.tgz#8d4f97b36efdfc82483eb8d3db64020767866f36"
integrity sha512-UHCYuqHipbTR1ZsXr5eg4JUmHER8Ss4YEb9Azn+9zzJ7/jlTtD1h0lc4g6tNx3eMlB8Mp6bfll0LPMAV4R6r3Q==
Expand Down Expand Up @@ -4627,18 +4627,18 @@ yargs@^14.0.0:
y18n "^4.0.0"
yargs-parser "^15.0.1"

youtube-sr@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/youtube-sr/-/youtube-sr-4.0.4.tgz#48369b0cb1c53bd84c366a5420bb8f35b1db2329"
integrity sha512-Wf6YlANcCjAweY2MQuqJqusmMcGzaSDWE6ZTD8vifb9i9oFyKQpWuV58fnebJCFJE8G8pTLidmj5aRV7x384EQ==
youtube-sr@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/youtube-sr/-/youtube-sr-4.0.6.tgz#e27c8fadb51361a6223ba0552b300f131c903fe9"
integrity sha512-nRrqgWl0xYfMhwLTqjF7G6s+36IHIdOMtZaSrz0Cpk4uSIqoeKEJgLiAZrYIGWGNYtS8/mzZYRzYxaIA/gW1Ig==
dependencies:
node-fetch "^2.6.1"
simple-youtube-api "^5.2.1"

ytdl-core@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/ytdl-core/-/ytdl-core-4.5.0.tgz#f07733387c548e5c3a5614c93ef55bde666eeaf4"
integrity sha512-e8r6skrakWNixsVlNPBMoRM1HrdW1swE97If9nenDUjF65uogYk4DvxIuqlmqRfBWKe+6aIZwqedNxUU9XLYJA==
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==
dependencies:
m3u8stream "^0.8.3"
miniget "^4.0.0"
Expand Down

0 comments on commit cf89dbe

Please sign in to comment.