Merge pull request #103 from netux/token-priority

Fix Client#connect()'s logic to prioritize the token parameter over Client#token
This commit is contained in:
DjDeveloper 2021-02-03 10:01:15 +05:30 committed by GitHub
commit 17a625032b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -291,10 +291,9 @@ export class Client extends HarmonyEventEmitter<ClientEvents> {
* @param intents Gateway intents in array. This is required if not given in ClientOptions.
*/
async connect(token?: string, intents?: GatewayIntents[]): Promise<Client> {
if (token === undefined && this.token !== undefined) token = this.token
else if (this.token === undefined && token !== undefined) {
this.token = token
} else throw new Error('No Token Provided')
token ??= this.token
if (token === undefined) throw new Error('No Token Provided')
this.token = token
if (intents !== undefined && this.intents !== undefined) {
this.debug(
'client',