Skip to content

Commit

Permalink
2.7.1
Browse files Browse the repository at this point in the history
- Fixes unintentional type errors
  • Loading branch information
Vexify4103 committed Jan 17, 2025
1 parent e5831a8 commit 7ff2923
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magmastream",
"version": "2.7.0",
"version": "2.7.1",
"description": "A user-friendly Lavalink client designed for NodeJS.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
25 changes: 6 additions & 19 deletions src/structures/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,30 +749,17 @@ export class Manager extends EventEmitter {
*/
public decodeTracks(tracks: string[]): Promise<TrackData[]> {
this.emit("debug", `[MANAGER] Decoding tracks: ${JSON.stringify(tracks)}`);

return new Promise(async (resolve, reject) => {
// Get the first available node for processing the decode request
const node = this.nodes.first();
if (!node) {
// Reject the promise if no nodes are available
return reject(new Error("No available nodes."));
}

try {
// Send a POST request to the Lavalink API to decode tracks
const res = await node.rest.post("/v4/decodetracks", JSON.stringify(tracks)) as TrackData[];
if (!node) throw new Error("No available nodes.");

// Check if a valid response is received
if (!res) {
return reject(new Error("No data returned from query."));
}
const res = (await node.rest.post("/v4/decodetracks", JSON.stringify(tracks)).catch((err) => reject(err))) as TrackData[];

// Resolve the promise with the decoded track data
resolve(res);
} catch (err) {
// Reject the promise if an error occurs during the API request
reject(err);
if (!res) {
return reject(new Error("No data returned from query."));
}

return resolve(res);
});
}

Expand Down
6 changes: 1 addition & 5 deletions src/structures/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ export class Player {
* @throws {TypeError} If the player is not connected.
*/
public disconnect(): this {
if (this.voiceChannel === null) {
throw new TypeError("The player is not connected.");
}
if (this.voiceChannel === null) return this;

this.state = "DISCONNECTING";

Expand Down Expand Up @@ -232,7 +230,6 @@ export class Player {
* @emits {playerStateUpdate} - The old and new player states after the destruction.
*/
public destroy(disconnect: boolean = true): void {
if (typeof disconnect !== "boolean") throw new TypeError("Disconnect must be a boolean.");

const oldPlayer = this ? { ...this } : null;
this.state = "DESTROYING";
Expand Down Expand Up @@ -527,7 +524,6 @@ export class Player {
*/
public setVolume(volume: number): this {
if (isNaN(volume)) throw new TypeError("Volume must be a number.");
if (volume < 0 || volume > 100) throw new RangeError("Volume must be between 0 and 100.");

const oldPlayer = this ? { ...this } : null;
this.node.rest.updatePlayer({
Expand Down

0 comments on commit 7ff2923

Please sign in to comment.