feat(Guild): add fetchBan method (#3726)

* Add error for not resolving ID to fetch ban

* Add Guild#fetchBan

* add missing !

* typings

* lint fixes

* add jsdoc description
This commit is contained in:
Sugden
2020-01-24 14:29:53 +00:00
committed by SpaceEEC
parent 63293fe14d
commit c779fe3670
3 changed files with 17 additions and 0 deletions

View File

@@ -554,6 +554,21 @@ class Guild extends Base {
* @property {?string} reason Reason the user was banned
*/
/**
* Fetches information on a banned user from this guild.
* @param {UserResolvable} user The User to fetch the ban info of
* @returns {BanInfo}
*/
fetchBan(user) {
const id = this.client.users.resolveID(user);
if (!id) throw new Error('FETCH_BAN_RESOLVE_ID');
return this.client.api.guilds(this.id).bans(id).get()
.then(ban => ({
reason: ban.reason,
user: this.client.users.add(ban.user),
}));
}
/**
* Fetches a collection of banned users in this guild.
* @returns {Promise<Collection<Snowflake, BanInfo>>}