From 026691702da7d1fcf9a959f00082f07f1e14b13d Mon Sep 17 00:00:00 2001 From: Carter <45381083+Fyko@users.noreply.github.com> Date: Mon, 27 Apr 2020 01:05:39 -0600 Subject: [PATCH] feat(Guild#fetch): withCount param (#4111) --- src/structures/Guild.js | 22 +++++++++++++++++++++- typings/index.d.ts | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 2275b41a0..38cf203e8 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -305,6 +305,26 @@ class Guild extends Base { */ if (typeof data.max_presences !== 'undefined') this.maximumPresences = data.max_presences || 25000; + /** + * The approximate amount of members the guild has + * You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter + * @type {?number} + * @name Guild#approximateMemberCount + */ + if (typeof data.approximate_member_count !== 'undefined') { + this.approximateMemberCount = data.approximate_member_count; + } + + /** + * The approximate amount of presences the guild has + * You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter + * @type {?number} + * @name Guild#approximatePresenceCount + */ + if (typeof data.approximate_presence_count !== 'undefined') { + this.approximatePresenceCount = data.approximate_presence_count; + } + /** * The vanity URL code of the guild, if any * @type {?string} @@ -593,7 +613,7 @@ class Guild extends Base { fetch() { return this.client.api .guilds(this.id) - .get() + .get({ query: { with_counts: true } }) .then(data => { this._patch(data); return this; diff --git a/typings/index.d.ts b/typings/index.d.ts index 32d60eee4..2dc5a7caf 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -588,6 +588,8 @@ declare module 'discord.js' { public afkChannelID: Snowflake | null; public afkTimeout: number; public applicationID: Snowflake | null; + public approximateMemberCount?: number; + public approximatePresenceCount?: number; public available: boolean; public banner: string | null; public channels: GuildChannelManager;