From 96bba8d68e5bc114f41ec2361293e7c85cb3b0d1 Mon Sep 17 00:00:00 2001 From: invalidCards <842080+invalidCards@users.noreply.github.com> Date: Mon, 1 Feb 2021 20:46:39 +0100 Subject: [PATCH 1/3] fix(BitField): resolve the bit before checking --- src/utils/bitfield.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/bitfield.ts b/src/utils/bitfield.ts index 9ca4c0b..e9cb4dd 100644 --- a/src/utils/bitfield.ts +++ b/src/utils/bitfield.ts @@ -27,7 +27,8 @@ export class BitField { has(bit: BitFieldResolvable, ...args: any[]): boolean { if (Array.isArray(bit)) return (bit.every as any)((p: any) => this.has(p)) - return (this.bitfield & BitField.resolve(this.flags, bit)) === bit + bit = BitField.resolve(this.flags, bit); + return (this.bitfield & bit) === bit } missing(bits: any, ...hasParams: any[]): string[] { From 38dea00369208a4643643337eefb3f93aca5550d Mon Sep 17 00:00:00 2001 From: invalidCards <842080+invalidCards@users.noreply.github.com> Date: Mon, 1 Feb 2021 20:49:27 +0100 Subject: [PATCH 2/3] Remove semicolon to conform to code style --- src/utils/bitfield.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/bitfield.ts b/src/utils/bitfield.ts index e9cb4dd..eb7a67c 100644 --- a/src/utils/bitfield.ts +++ b/src/utils/bitfield.ts @@ -27,7 +27,7 @@ export class BitField { has(bit: BitFieldResolvable, ...args: any[]): boolean { if (Array.isArray(bit)) return (bit.every as any)((p: any) => this.has(p)) - bit = BitField.resolve(this.flags, bit); + bit = BitField.resolve(this.flags, bit) return (this.bitfield & bit) === bit } From 7af4553fbef9706e63a5aefa6a8946322dadc363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20=28Netux=29=20Rodr=C3=ADguez?= Date: Wed, 3 Feb 2021 01:17:01 -0300 Subject: [PATCH 3/3] 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. --- src/models/client.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/models/client.ts b/src/models/client.ts index 6c8b872..83846cd 100644 --- a/src/models/client.ts +++ b/src/models/client.ts @@ -291,10 +291,9 @@ export class Client extends HarmonyEventEmitter { * @param intents Gateway intents in array. This is required if not given in ClientOptions. */ async connect(token?: string, intents?: GatewayIntents[]): Promise { - 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',