Fix Client#connect()'s logic to prioritize the token parameter over Client#token
When Client#token was set and the token parameter is passed to Client#connect(), the module would throw an 'No Token Provided' error. This change makes it prioritize the parameter over Client#token.
This commit is contained in:
		
							parent
							
								
									6a8e4ddc43
								
							
						
					
					
						commit
						7af4553fbe
					
				
					 1 changed files with 3 additions and 4 deletions
				
			
		|  | @ -291,10 +291,9 @@ export class Client extends HarmonyEventEmitter<ClientEvents> { | ||||||
|    * @param intents Gateway intents in array. This is required if not given in ClientOptions. |    * @param intents Gateway intents in array. This is required if not given in ClientOptions. | ||||||
|    */ |    */ | ||||||
|   async connect(token?: string, intents?: GatewayIntents[]): Promise<Client> { |   async connect(token?: string, intents?: GatewayIntents[]): Promise<Client> { | ||||||
|     if (token === undefined && this.token !== undefined) token = this.token |     token ??= this.token | ||||||
|     else if (this.token === undefined && token !== undefined) { |     if (token === undefined) throw new Error('No Token Provided') | ||||||
|       this.token = token |     this.token = token | ||||||
|     } else throw new Error('No Token Provided') |  | ||||||
|     if (intents !== undefined && this.intents !== undefined) { |     if (intents !== undefined && this.intents !== undefined) { | ||||||
|       this.debug( |       this.debug( | ||||||
|         'client', |         'client', | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue