diff --git a/example/package.json b/example/package.json index 75a4425..0617c90 100644 --- a/example/package.json +++ b/example/package.json @@ -10,6 +10,6 @@ "dependencies": { "discord.js": "^14.15.3", "dotenv": "^16.4.5", - "sunday.ts": "^1.0.3-indev" + "sunday.ts": "latest" } -} \ No newline at end of file +} diff --git a/package.json b/package.json index ae52bb4..b6669e7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "sunday.ts", "main": "dist/index.js", "types": "dist/index.d.ts", - "version": "1.1.1", + "version": "1.1.2", "description": "Sunday a lavalink wrapper", "license": "MIT", "author": "EwarinDev", @@ -28,9 +28,9 @@ "access": "public" }, "bugs": { - "url": "https://github.com/FAYStarNext/Sunday.ts/issues" + "url": "https://github.com/EwarinDev/Sunday.ts/issues" }, - "homepage": "https://github.com/FAYStarNext/Sunday.ts#readme", + "homepage": "https://github.com/EwarinDev/Sunday.ts#readme", "peerDependencies": { "typescript": "^5.5.4" }, diff --git a/src/Structures/Manager.ts b/src/Structures/Manager.ts index 8fba726..57b443d 100644 --- a/src/Structures/Manager.ts +++ b/src/Structures/Manager.ts @@ -97,11 +97,10 @@ export class Manager extends TypedEmitter { super(); managerCheck(options); - Structure.get("Player").init(this); Structure.get("Node").init(this); TrackUtils.init(this); - + if (options.trackPartial) { TrackUtils.setTrackPartial(options.trackPartial); delete options.trackPartial; @@ -134,7 +133,10 @@ export class Manager extends TypedEmitter { } if (this.options.nodes) { - for (const nodeOptions of this.options.nodes) new (Structure.get("Node"))(nodeOptions); + for (const nodeOptions of this.options.nodes) { + const node = new (Structure.get("Node"))(nodeOptions); + this.nodes.set(node.options.identifier, node); + } } } @@ -263,17 +265,18 @@ export class Manager extends TypedEmitter { * @param tracks */ public decodeTracks(tracks: string[]): Promise { - return new Promise(async (resolve, reject) => { + return new Promise(async(resolve, reject) => { const node = this.nodes.first(); - if (!node) throw new Error("No available nodes."); - - const res = (await node.rest.post("/v4/decodetracks", JSON.stringify(tracks)).catch((err) => reject(err))) as TrackData[]; - - if (!res) { - return reject(new Error("No data returned from query.")); + if (!node) { + return reject(new Error("No available nodes.")); } - - return resolve(res); + + await node.rest.post("/v4/decodetracks", JSON.stringify(tracks)) + .then((res) => { + if (!res) return reject(new Error("No data returned from query.")); + resolve(res as TrackData[]); + }) + .catch((err) => reject(err)); }); }