From 7ba1ed9b5d237503143714248aac0ca2b13ac62f Mon Sep 17 00:00:00 2001 From: ArviX#8443 <50046996+LordAlex2015@users.noreply.github.com> Date: Fri, 15 Jul 2022 10:05:00 +0200 Subject: [PATCH 1/4] :bug: Fixed mixed players from different instances. --- src/structures/Manager.ts | 8 ++++++-- src/structures/Player.ts | 11 ++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/structures/Manager.ts b/src/structures/Manager.ts index c1f4a49..fcf7849 100644 --- a/src/structures/Manager.ts +++ b/src/structures/Manager.ts @@ -68,7 +68,7 @@ function check(options: ManagerOptions) { typeof options.clientName !== "string" ) throw new TypeError('Manager option "clientName" must be a string.'); - + if ( typeof options.defaultSearchPlatform !== "undefined" && typeof options.defaultSearchPlatform !== "string" @@ -420,6 +420,10 @@ export class Manager extends EventEmitter { */ public create(options: PlayerOptions): Player { if (this.players.has(options.guild)) { + if(this.players.get(options.guild).manager.options.clientId !== this.options.clientId) { + Object.assign({ manager: this, clientId: this.options.clientId }, options); + return new (Structure.get("Player"))(options); + } return this.players.get(options.guild); } @@ -484,7 +488,7 @@ export class Manager extends EventEmitter { } else { /* voice state update */ if (update.user_id !== this.options.clientId) { - return; + return; } if (update.channel_id) { diff --git a/src/structures/Player.ts b/src/structures/Player.ts index ed76154..95f079a 100644 --- a/src/structures/Player.ts +++ b/src/structures/Player.ts @@ -108,7 +108,12 @@ export class Player { if (!this.manager) throw new RangeError("Manager has not been initiated."); if (this.manager.players.has(options.guild)) { - return this.manager.players.get(options.guild); + if(this.manager.players.get(options.guild).manager.options.clientId === options.clientId) { + return this.manager.players.get(options.guild); + } else { + this.manager = options.manager; + } + delete this.options.manager; delete this.options.clientId; } check(options); @@ -463,6 +468,10 @@ export interface PlayerOptions { selfMute?: boolean; /** If the player should deaf itself. */ selfDeafen?: boolean; + /** Client Id to check if no corruption is detected. */ + clientId?: string; + /** Manager to set in case corruption is detected. */ + manager: Manager; } /** If track partials are set some of these will be `undefined` as they were removed. */ From 7ff73c53fb9d25e5ec853a6280e545b5f0c9e4cf Mon Sep 17 00:00:00 2001 From: ArviX#8443 <50046996+LordAlex2015@users.noreply.github.com> Date: Fri, 15 Jul 2022 10:08:45 +0200 Subject: [PATCH 2/4] :ambulance: Type Doc Mismatch --- src/structures/Player.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Player.ts b/src/structures/Player.ts index 95f079a..a5154d9 100644 --- a/src/structures/Player.ts +++ b/src/structures/Player.ts @@ -471,7 +471,7 @@ export interface PlayerOptions { /** Client Id to check if no corruption is detected. */ clientId?: string; /** Manager to set in case corruption is detected. */ - manager: Manager; + manager?: Manager; } /** If track partials are set some of these will be `undefined` as they were removed. */ From 53246be0c7fa90a486057dd005ad74f82c58d113 Mon Sep 17 00:00:00 2001 From: ArviX#8443 <50046996+LordAlex2015@users.noreply.github.com> Date: Fri, 15 Jul 2022 10:31:46 +0200 Subject: [PATCH 3/4] :ambulance: Fixing my stuff --- src/structures/Manager.ts | 2 +- src/structures/Player.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/structures/Manager.ts b/src/structures/Manager.ts index fcf7849..e537b59 100644 --- a/src/structures/Manager.ts +++ b/src/structures/Manager.ts @@ -419,9 +419,9 @@ export class Manager extends EventEmitter { * @param options */ public create(options: PlayerOptions): Player { + Object.assign({ manager: this, clientId: this.options.clientId }, options); if (this.players.has(options.guild)) { if(this.players.get(options.guild).manager.options.clientId !== this.options.clientId) { - Object.assign({ manager: this, clientId: this.options.clientId }, options); return new (Structure.get("Player"))(options); } return this.players.get(options.guild); diff --git a/src/structures/Player.ts b/src/structures/Player.ts index a5154d9..8dd2793 100644 --- a/src/structures/Player.ts +++ b/src/structures/Player.ts @@ -111,11 +111,13 @@ export class Player { if(this.manager.players.get(options.guild).manager.options.clientId === options.clientId) { return this.manager.players.get(options.guild); } else { - this.manager = options.manager; + if(options.manager) this.manager = options.manager; } - delete this.options.manager; delete this.options.clientId; } - + if(this.manager.options.clientId !== options.clientId) { + if(options.manager) this.manager = options.manager; + } + delete this.options.manager; delete this.options.clientId; check(options); this.guild = options.guild; From 1b5b9b3c0e4e6abbfd8ac5bf29644bb0dd2495f4 Mon Sep 17 00:00:00 2001 From: ArviX#8443 <50046996+LordAlex2015@users.noreply.github.com> Date: Fri, 15 Jul 2022 10:37:35 +0200 Subject: [PATCH 4/4] :ambulance: Still Fixing my stuff --- src/structures/Manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Manager.ts b/src/structures/Manager.ts index e537b59..eb4af5c 100644 --- a/src/structures/Manager.ts +++ b/src/structures/Manager.ts @@ -419,7 +419,7 @@ export class Manager extends EventEmitter { * @param options */ public create(options: PlayerOptions): Player { - Object.assign({ manager: this, clientId: this.options.clientId }, options); + options.manager = this; options.clientId = this.options.clientId; if (this.players.has(options.guild)) { if(this.players.get(options.guild).manager.options.clientId !== this.options.clientId) { return new (Structure.get("Player"))(options);