mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
committed by
Schuyler Cebulskie
parent
529d7207da
commit
15d7f8e2fe
File diff suppressed because one or more lines are too long
@@ -507,6 +507,15 @@ class RESTMethods {
|
|||||||
}).catch(reject);
|
}).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;
|
module.exports = RESTMethods;
|
||||||
|
|||||||
@@ -504,6 +504,27 @@ class Guild {
|
|||||||
return create.then(role => role.edit(data));
|
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.
|
* Causes the Client to leave the guild.
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
|
|||||||
Reference in New Issue
Block a user