diff --git a/src/stores/GuildMemberStore.js b/src/stores/GuildMemberStore.js index 397c119b7..9f9c42117 100644 --- a/src/stores/GuildMemberStore.js +++ b/src/stores/GuildMemberStore.js @@ -106,11 +106,13 @@ class GuildMemberStore extends DataStore { /** * Prunes members from the guild based on how long they have been inactive. + * It's recommended to set options.count to `false` for large guilds. * @param {Object} [options] Prune options * @param {number} [options.days=7] Number of days of inactivity required to kick * @param {boolean} [options.dry=false] Get number of users that will be kicked, without actually kicking them + * @param {boolean} [options.count=true] Whether or not to return the number of users that have been kicked. * @param {string} [options.reason] Reason for this prune - * @returns {Promise} The number of members that were/will be kicked + * @returns {Promise} The number of members that were/will be kicked * @example * // See how many members will be pruned * guild.members.prune({ dry: true }) @@ -122,9 +124,12 @@ class GuildMemberStore extends DataStore { * .then(pruned => console.log(`I just pruned ${pruned} people!`)) * .catch(console.error); */ - prune({ days = 7, dry = false, reason } = {}) { + prune({ days = 7, dry = false, count = true, reason } = {}) { if (typeof days !== 'number') throw new TypeError('PRUNE_DAYS_TYPE'); - return this.client.api.guilds(this.guild.id).prune[dry ? 'get' : 'post']({ query: { days }, reason }) + return this.client.api.guilds(this.guild.id).prune[dry ? 'get' : 'post']({ query: { + days, + compute_prune_count: count, + }, reason }) .then(data => data.pruned); } diff --git a/typings/index.d.ts b/typings/index.d.ts index 45f2b582e..99b0962e0 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1430,6 +1430,7 @@ declare module 'discord.js' { public fetch(options: UserResolvable | FetchMemberOptions): Promise; public fetch(): Promise; public fetch(options: FetchMembersOptions): Promise>; + public prune(options: GuildPruneMembersOptions & { dry?: false, count: false }): Promise; public prune(options?: GuildPruneMembersOptions): Promise; public unban(user: UserResolvable, reason?: string): Promise; } @@ -1901,6 +1902,7 @@ declare module 'discord.js' { type GuildResolvable = Guild | Snowflake; interface GuildPruneMembersOptions { + count?: boolean; days?: number; dry?: boolean; reason?: string;