From f9215dd7946db788cd71fe8a8358c7fcde95a9f9 Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Mon, 16 Aug 2021 03:39:13 -0400 Subject: [PATCH 01/11] Add maximumBitrate Property on Guild --- src/structures/Guild.js | 27 +++++++++++++++++++++++++++ typings/index.d.ts | 1 + 2 files changed, 28 insertions(+) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 9a8759e73003..1b7565ffcd4d 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -316,6 +316,33 @@ class Guild extends AnonymousGuild { this.approximatePresenceCount = null; } + /** + * The maximum bitrate based on the guild premium_tiers level and the features + * @type {?number} + */ + this.maximumBitrate = 96000; + + if (this.features.includes('VIP_REGIONS')) { + this.maximumBitrate = 384000; + } else { + switch (data.premium_tier) { + case 0: + this.maximumBitrate = 96000; + break; + case 1: + this.maximumBitrate = 128000; + break; + case 2: + this.maximumBitrate = 256000; + break; + case 3: + this.maximumBitrate = 384000; + break; + default: + this.maximumBitrate = 96000; + } + } + /** * The use count of the vanity URL code of the guild, if any * You will need to fetch this parameter using {@link Guild#fetchVanityData} if you want to receive it diff --git a/typings/index.d.ts b/typings/index.d.ts index ab686cb62202..0b27560bc034 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -691,6 +691,7 @@ export class Guild extends AnonymousGuild { public readonly widgetChannel: TextChannel | null; public widgetChannelId: Snowflake | null; public widgetEnabled: boolean | null; + public maximumBitrate: number; public createTemplate(name: string, description?: string): Promise; public delete(): Promise; public discoverySplashURL(options?: StaticImageURLOptions): string | null; From 6e2e66ca421f523b82ca1d5515356db1155b5646 Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Mon, 16 Aug 2021 03:54:36 -0400 Subject: [PATCH 02/11] Fix eslint check --- src/structures/Guild.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 1b7565ffcd4d..ed42b1e1c755 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -317,9 +317,9 @@ class Guild extends AnonymousGuild { } /** - * The maximum bitrate based on the guild premium_tiers level and the features - * @type {?number} - */ + * The maximum bitrate based on the guild premium_tiers level and the features + * @type {?number} + */ this.maximumBitrate = 96000; if (this.features.includes('VIP_REGIONS')) { From 67e21ef0032876c6a30b9a78979710ea57fbeff7 Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Mon, 16 Aug 2021 21:24:05 -0400 Subject: [PATCH 03/11] Move .maximumBitrate into a getter --- src/structures/Guild.js | 51 +++++++++++++++++++---------------------- typings/index.d.ts | 2 +- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index ed42b1e1c755..57c01cfb2c0e 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -316,33 +316,6 @@ class Guild extends AnonymousGuild { this.approximatePresenceCount = null; } - /** - * The maximum bitrate based on the guild premium_tiers level and the features - * @type {?number} - */ - this.maximumBitrate = 96000; - - if (this.features.includes('VIP_REGIONS')) { - this.maximumBitrate = 384000; - } else { - switch (data.premium_tier) { - case 0: - this.maximumBitrate = 96000; - break; - case 1: - this.maximumBitrate = 128000; - break; - case 2: - this.maximumBitrate = 256000; - break; - case 3: - this.maximumBitrate = 384000; - break; - default: - this.maximumBitrate = 96000; - } - } - /** * The use count of the vanity URL code of the guild, if any * You will need to fetch this parameter using {@link Guild#fetchVanityData} if you want to receive it @@ -561,6 +534,30 @@ class Guild extends AnonymousGuild { ); } + /** + * Return maximum bitrate based on the guild premium_tiers level and the features + * @type {?number} + * @readonly + */ + get maximumBitrate() { + if (this.features.includes('VIP_REGIONS')) { + return 384000; + } else { + switch (this.premiumTier) { + case PremiumTiers.indexOf(this.premiumTier) === 0: + return 96000; + case PremiumTiers.indexOf(this.premiumTier) === 1: + return 128000; + case PremiumTiers.indexOf(this.premiumTier) === 2: + return 256000; + case PremiumTiers.indexOf(this.premiumTier) === 3: + return 384000; + default: + return 96000; + } + } + } + /** * Fetches a collection of integrations to this guild. * Resolves with a collection mapping integrations by their ids. diff --git a/typings/index.d.ts b/typings/index.d.ts index 0b27560bc034..b6bca2a87404 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -691,7 +691,7 @@ export class Guild extends AnonymousGuild { public readonly widgetChannel: TextChannel | null; public widgetChannelId: Snowflake | null; public widgetEnabled: boolean | null; - public maximumBitrate: number; + public readonly maximumBitrate: number; public createTemplate(name: string, description?: string): Promise; public delete(): Promise; public discoverySplashURL(options?: StaticImageURLOptions): string | null; From 4865cb779780a8f4870cbdab21ca2d384832c256 Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Mon, 16 Aug 2021 22:21:20 -0400 Subject: [PATCH 04/11] Update src/structures/Guild.js Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- src/structures/Guild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 57c01cfb2c0e..48ba3982ae50 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -536,7 +536,7 @@ class Guild extends AnonymousGuild { /** * Return maximum bitrate based on the guild premium_tiers level and the features - * @type {?number} + * @type {number} * @readonly */ get maximumBitrate() { From 6541c9784ac57c1bea9d85c8c28d10de48e065ae Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Mon, 16 Aug 2021 22:21:55 -0400 Subject: [PATCH 05/11] Update src/structures/Guild.js Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- src/structures/Guild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 48ba3982ae50..fadbff39f626 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -535,7 +535,7 @@ class Guild extends AnonymousGuild { } /** - * Return maximum bitrate based on the guild premium_tiers level and the features + * The maximum bitrate available for this guild * @type {number} * @readonly */ From b2977e7159666e57e9210c0fb7aa970ac96c0464 Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Mon, 16 Aug 2021 22:41:13 -0400 Subject: [PATCH 06/11] Fix getting enum index value --- src/structures/Guild.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 57c01cfb2c0e..e4d65d752b87 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -544,13 +544,13 @@ class Guild extends AnonymousGuild { return 384000; } else { switch (this.premiumTier) { - case PremiumTiers.indexOf(this.premiumTier) === 0: + case PremiumTiers[this.premiumTier] === 0: return 96000; - case PremiumTiers.indexOf(this.premiumTier) === 1: + case PremiumTiers[this.premiumTier] === 1: return 128000; - case PremiumTiers.indexOf(this.premiumTier) === 2: + case PremiumTiers[this.premiumTier] === 2: return 256000; - case PremiumTiers.indexOf(this.premiumTier) === 3: + case PremiumTiers[this.premiumTier] === 3: return 384000; default: return 96000; From dee0ceb61bc2d49aa5cbaf647628ece9a412bde9 Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Tue, 17 Aug 2021 03:12:59 -0400 Subject: [PATCH 07/11] Change switch check --- src/structures/Guild.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 28dd505ffce6..2433f6f765db 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -542,19 +542,19 @@ class Guild extends AnonymousGuild { get maximumBitrate() { if (this.features.includes('VIP_REGIONS')) { return 384000; - } else { - switch (this.premiumTier) { - case PremiumTiers[this.premiumTier] === 0: - return 96000; - case PremiumTiers[this.premiumTier] === 1: - return 128000; - case PremiumTiers[this.premiumTier] === 2: - return 256000; - case PremiumTiers[this.premiumTier] === 3: - return 384000; - default: - return 96000; - } + } + + switch (PremiumTiers[this.premiumTier]) { + case 0: + return 96000; + case 1: + return 128000; + case 2: + return 256000; + case 3: + return 384000; + default: + return 96000; } } From bc0b46cbba1dcb4398c4c5b18d85debbbb2665be Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Tue, 17 Aug 2021 16:36:43 -0400 Subject: [PATCH 08/11] Update src/structures/Guild.js Never used a switch like this. Nice to know! Co-authored-by: Sugden <28943913+NotSugden@users.noreply.github.com> --- src/structures/Guild.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 2433f6f765db..27075f8530da 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -545,6 +545,7 @@ class Guild extends AnonymousGuild { } switch (PremiumTiers[this.premiumTier]) { + default: case 0: return 96000; case 1: From 39ef7317b40168d8878f2158f381f0c28d81ffb7 Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Tue, 17 Aug 2021 16:55:36 -0400 Subject: [PATCH 09/11] Improve switch statement --- src/structures/Guild.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 27075f8530da..5c35020f9226 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -542,12 +542,8 @@ class Guild extends AnonymousGuild { get maximumBitrate() { if (this.features.includes('VIP_REGIONS')) { return 384000; - } - + } switch (PremiumTiers[this.premiumTier]) { - default: - case 0: - return 96000; case 1: return 128000; case 2: From 3fe2888647c57f218725a4e3865ae193354746d8 Mon Sep 17 00:00:00 2001 From: Francis Rivard Date: Wed, 18 Aug 2021 01:51:10 -0400 Subject: [PATCH 10/11] Update src/structures/Guild.js MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antonio Román --- src/structures/Guild.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 5c35020f9226..4f067c617bf0 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -544,11 +544,11 @@ class Guild extends AnonymousGuild { return 384000; } switch (PremiumTiers[this.premiumTier]) { - case 1: + case PremiumTiers.TIER_1: return 128000; - case 2: + case PremiumTiers.TIER_2: return 256000; - case 3: + case PremiumTiers.TIER_3: return 384000; default: return 96000; From d8df35f1588a36d402377b09ed2f10b619102595 Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Mon, 23 Aug 2021 14:34:16 +0200 Subject: [PATCH 11/11] Update src/structures/Guild.js --- src/structures/Guild.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 4f067c617bf0..5a6d06746819 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -543,6 +543,7 @@ class Guild extends AnonymousGuild { if (this.features.includes('VIP_REGIONS')) { return 384000; } + switch (PremiumTiers[this.premiumTier]) { case PremiumTiers.TIER_1: return 128000;