diff --git a/README.md b/README.md index 14375918..8a743b7a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ A Discord.js module to simplify your music commands and play songs with audio fi ## Installation ```npm -npm install distube +npm install distube@latest ``` ### Requirement diff --git a/package.json b/package.json index 864f60c9..1b16314a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "distube", - "version": "3.0.3", + "version": "3.0.4", "description": "A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key. Support YouTube, SoundCloud, Bandcamp, Facebook, and 700+ more sites", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/core/__test__/DisTubeOptions.test.ts b/src/core/__test__/DisTubeOptions.test.ts index cf9f9f48..c9e452d4 100644 --- a/src/core/__test__/DisTubeOptions.test.ts +++ b/src/core/__test__/DisTubeOptions.test.ts @@ -27,23 +27,23 @@ test("Validate DisTubeOptions", () => { const n: any = NaN; expect(() => { new Options(n); - }).toThrow("Expected 'object' for 'DisTubeOptions', but got NaN"); + }).toThrow("Expected 'object' for 'DisTubeOptions', but got null (Number)"); for (const key of Object.keys(defaultOptions).filter(o => o !== "plugins")) { const options = {}; options[key] = n; expect(() => { new Options(options); - }).toThrow(`Expected '${typeof defaultOptions[key]}' for 'DisTubeOptions.${key}', but got NaN`); + }).toThrow(`Expected '${typeof defaultOptions[key]}' for 'DisTubeOptions.${key}', but got null (Number)`); } expect(() => { new Options({ plugins: "undefined" as any }); - }).toThrow("Expected 'Array' for 'DisTubeOptions.plugins', but got 'undefined'"); + }).toThrow("Expected 'Array' for 'DisTubeOptions.plugins', but got \"undefined\" (String)"); expect(() => { new Options({ youtubeCookie: 1 as any }); - }).toThrow("Expected 'string' for 'DisTubeOptions.youtubeCookie', but got 1"); + }).toThrow("Expected 'string' for 'DisTubeOptions.youtubeCookie', but got 1 (Number)"); expect(() => { new Options({ youtubeIdentityToken: {} as any }); - }).toThrow("Expected 'string' for 'DisTubeOptions.youtubeIdentityToken', but got Object"); + }).toThrow("Expected 'string' for 'DisTubeOptions.youtubeIdentityToken', but got {} (Object)"); expect(() => { new Options({ invalidKey: "an invalid key" } as any); }).toThrow("'invalidKey' does not need to be provided in DisTubeOptions"); diff --git a/src/core/manager/QueueManager.ts b/src/core/manager/QueueManager.ts index 23f66651..72791d4f 100644 --- a/src/core/manager/QueueManager.ts +++ b/src/core/manager/QueueManager.ts @@ -143,8 +143,6 @@ export class QueueManager extends BaseManager { return true; } if (queue.stopped) return false; - queue.playing = true; - queue.paused = false; const song = queue.songs[0]; try { const { url, source, formats, streamURL } = song; @@ -163,6 +161,8 @@ export class QueueManager extends BaseManager { const stream = this.handler.createStream(queue); queue.voice.play(stream); song.streamURL = stream.url; + if (queue.stopped) queue.stop(); + else if (queue.paused) queue.voice.pause(); return false; } catch (e: any) { this._handlePlayingError(queue, e); diff --git a/src/struct/DisTubeError.ts b/src/struct/DisTubeError.ts index ddc64e29..7688f248 100644 --- a/src/struct/DisTubeError.ts +++ b/src/struct/DisTubeError.ts @@ -2,15 +2,7 @@ const ERROR_MESSAGES = { INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string) => `Expected ${ Array.isArray(expected) ? expected.map(e => (typeof e === "number" ? e : `'${e}'`)).join(" or ") : `'${expected}'` - }${name ? ` for '${name}'` : ""}, but got ${ - typeof got === "string" - ? `'${got}'` - : typeof got === "number" - ? got - : Array.isArray(got) - ? `Array<${got.length}>` - : got?.constructor?.name || typeof got - } (${typeof got})`, + }${name ? ` for '${name}'` : ""}, but got ${JSON.stringify(got)} (${got?.constructor?.name ?? typeof got})`, NUMBER_COMPARE: (name: string, expected: string, value: number) => `'${name}' must be ${expected} ${value}`, EMPTY_ARRAY: (name: string) => `'${name}' is an empty array`, EMPTY_FILTERED_ARRAY: (name: string, type: string) => `There is no valid '${type}' in the '${name}' array`,