feat(Guild#fetch): withCount param (#4111)

This commit is contained in:
Carter
2020-04-27 01:05:39 -06:00
committed by GitHub
parent 605ee8587b
commit 026691702d
2 changed files with 23 additions and 1 deletions

View File

@@ -305,6 +305,26 @@ class Guild extends Base {
*/ */
if (typeof data.max_presences !== 'undefined') this.maximumPresences = data.max_presences || 25000; if (typeof data.max_presences !== 'undefined') this.maximumPresences = data.max_presences || 25000;
/**
* The approximate amount of members the guild has
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* @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
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* @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 * The vanity URL code of the guild, if any
* @type {?string} * @type {?string}
@@ -593,7 +613,7 @@ class Guild extends Base {
fetch() { fetch() {
return this.client.api return this.client.api
.guilds(this.id) .guilds(this.id)
.get() .get({ query: { with_counts: true } })
.then(data => { .then(data => {
this._patch(data); this._patch(data);
return this; return this;

2
typings/index.d.ts vendored
View File

@@ -588,6 +588,8 @@ declare module 'discord.js' {
public afkChannelID: Snowflake | null; public afkChannelID: Snowflake | null;
public afkTimeout: number; public afkTimeout: number;
public applicationID: Snowflake | null; public applicationID: Snowflake | null;
public approximateMemberCount?: number;
public approximatePresenceCount?: number;
public available: boolean; public available: boolean;
public banner: string | null; public banner: string | null;
public channels: GuildChannelManager; public channels: GuildChannelManager;