mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 00:53:31 +01:00
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:
@@ -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>>}
|
||||
|
||||
Reference in New Issue
Block a user