mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
feat(GuildMemberStore) add options.count to prune (#3189)
* add GuildMemberStore#prune(options.count) * typings: proper typings for null return value
This commit is contained in:
@@ -106,11 +106,13 @@ class GuildMemberStore extends DataStore {
|
||||
|
||||
/**
|
||||
* Prunes members from the guild based on how long they have been inactive.
|
||||
* <info>It's recommended to set options.count to `false` for large guilds.</info>
|
||||
* @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<number>} The number of members that were/will be kicked
|
||||
* @returns {Promise<number|null>} 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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user