Merge branch develop (#1287)

* fix(Queue): shuffle all tracks

* Shuffled first track as well

* Fixed queue shuffling to include first element

* fix(AudioFilters): properly get filters

* 5.3.1

Co-authored-by: mjh <61671361+mjh316@users.noreply.github.com>
This commit is contained in:
benny 2022-08-08 20:48:24 +05:45 committed by GitHub
parent bf22b25342
commit 8d7b841d9a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 11 deletions

View file

@ -1,6 +1,6 @@
{
"name": "discord-player",
"version": "5.3.0",
"version": "5.3.1",
"description": "Complete framework to facilitate music commands using discord.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
@ -18,7 +18,7 @@
"./dist/*": "./dist/*"
},
"scripts": {
"dev": "cd example/test && ts-node index.ts",
"dev": "cd examples/test && ts-node index.ts",
"build": "rimraf dist && tsc && npm run build:esm",
"build:check": "tsc --noEmit --incremental false",
"prepublishOnly": "rollup-type-bundler -e stream",

View file

@ -455,16 +455,13 @@ class Queue<T = unknown> {
*/
shuffle() {
if (this.#watchDestroyed()) return;
if (!this.tracks.length || this.tracks.length < 3) return false;
const currentTrack = this.tracks.shift();
if (!this.tracks.length || this.tracks.length < 2) return false;
for (let i = this.tracks.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[this.tracks[i], this.tracks[j]] = [this.tracks[j], this.tracks[i]];
}
this.tracks.unshift(currentTrack);
return true;
}

View file

@ -54,18 +54,18 @@ class AudioFilters {
}
public static *[Symbol.iterator](): IterableIterator<{ name: FiltersName; value: string }> {
for (const [k, v] of Object.entries(this)) {
if (typeof this.filters[k as FiltersName] === "string") yield { name: k as FiltersName, value: v as string };
for (const [k, v] of Object.entries(this.filters)) {
yield { name: k as FiltersName, value: v as string };
}
}
public static get names() {
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this.filters[p as FiltersName] !== "function") as FiltersName[];
return Object.keys(this.filters) as FiltersName[];
}
// @ts-expect-error AudioFilters.length
public static get length() {
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this.filters[p as FiltersName] !== "function").length;
return this.names.length;
}
public static toString() {
@ -77,7 +77,7 @@ class AudioFilters {
* @param filter The filter name
* @returns
*/
public static create(filters?: FiltersName[]) {
public static create<K extends FiltersName>(filters?: K[]) {
if (!filters || !Array.isArray(filters)) return this.toString();
return filters
.filter((predicate) => typeof predicate === "string")