mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
parent
529d7207da
commit
15d7f8e2fe
3 changed files with 31 additions and 1 deletions
File diff suppressed because one or more lines are too long
|
|
@ -507,6 +507,15 @@ class RESTMethods {
|
|||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
pruneGuildMembers(guild, days, dry) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.makeRequest(dry ? 'get' : 'post', `${Constants.Endpoints.guildPrune(guild.id)}?days=${days}`, true)
|
||||
.then(data => {
|
||||
resolve(data.pruned);
|
||||
}).catch(reject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RESTMethods;
|
||||
|
|
|
|||
|
|
@ -504,6 +504,27 @@ class Guild {
|
|||
return create.then(role => role.edit(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prunes members from the guild based on how long they have been inactive.
|
||||
* @param {number} days Number of days of inactivity required to kick
|
||||
* @param {boolean} [dry=false] If true, will return number of users that will be kicked, without actually doing it
|
||||
* @returns {Promise<number>} The number of members that were/will be kicked
|
||||
* @example
|
||||
* // see how many members will be pruned
|
||||
* guild.prune(12, true)
|
||||
* .then(pruned => console.log(`This will prune ${pruned} people!`);
|
||||
* .catch(console.error);
|
||||
* @example
|
||||
* // actually prune the members
|
||||
* guild.prune(12)
|
||||
* .then(pruned => console.log(`I just pruned ${pruned} people!`);
|
||||
* .catch(console.error);
|
||||
*/
|
||||
prune(days, dry = false) {
|
||||
if (typeof days !== 'number') throw new TypeError('Days must be a number.');
|
||||
return this.client.rest.methods.pruneGuildMembers(this, days, dry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Causes the Client to leave the guild.
|
||||
* @returns {Promise<Guild>}
|
||||
|
|
|
|||
Loading…
Reference in a new issue