diff --git a/src/structures/Manager.ts b/src/structures/Manager.ts index c1f4a49..eb4af5c 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" @@ -419,7 +419,11 @@ export class Manager extends EventEmitter { * @param options */ public create(options: PlayerOptions): Player { + 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); + } 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..8dd2793 100644 --- a/src/structures/Player.ts +++ b/src/structures/Player.ts @@ -108,9 +108,16 @@ 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 { + if(options.manager) this.manager = options.manager; + } } - + 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; @@ -463,6 +470,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. */