class GuildBanManager
extends
CachedManager<Snowflake, GuildBan, GuildBanResolvable>export class GuildBanManager extends CachedManager<Snowflake, GuildBan, GuildBanResolvable>
Manages API methods for guild bans and stores their cache.
readonlyCollection<Key, Holds> cache :
The cache of items for this manager.
Inherited from: DataManager
Guild guild :
The guild this Manager belongs to
readonlyConstructable<Holds> holds :
The data structure belonging to this manager.
Inherited from: DataManager
bulkCreateusers: ReadonlyCollection<Snowflake, UserResolvable> | readonly UserResolvable[]options?: BanOptions) : Promise<BulkBanResult> (
users: ReadonlyCollection<Snowflake, UserResolvable> | readonly UserResolvable[]
options?: BanOptions
Bulk ban users from a guild, and optionally delete previous messages sent by them.
Examples:
// Bulk ban users by ids (or with user/guild member objects) and delete all their messages from the past 7 days
guild.bans.bulkCreate(['84484653687267328'], { deleteMessageSeconds: 7 * 24 * 60 * 60 })
.then(result => {
console.log(`Banned ${result.bannedUsers.length} users, failed to ban ${result.failedUsers.length} users.`)
})
.catch(console.error);
Returns: Returns an object with bannedUsers
key containing the IDs of the banned users and the key failedUsers
with the IDs that could not be banned or were already banned.
createuser: UserResolvableoptions?: BanOptions = {}) : Promise<void> (
user: UserResolvable
options?: BanOptions = {}
Bans a user from the guild.
Examples:
// Ban a user by id (or with a user/guild member object)
await guild.bans.create('84484653687267328');
Overload 1
Overload 2
fetchoptions: UserResolvable | FetchBanOptions) : Promise<GuildBan> (
options: UserResolvable | FetchBanOptions
Fetches ban(s) from Discord.
Examples:
// Fetch multiple bans from a guild
guild.bans.fetch()
.then(console.log)
.catch(console.error);
// Fetch a maximum of 5 bans from a guild without caching
guild.bans.fetch({ limit: 5, cache: false })
.then(console.log)
.catch(console.error);
// Fetch a single ban
guild.bans.fetch('351871113346809860')
.then(console.log)
.catch(console.error);
// Fetch a single ban without checking cache
guild.bans.fetch({ user, force: true })
.then(console.log)
.catch(console.error)
// Fetch a single ban without caching
guild.bans.fetch({ user, cache: false })
.then(console.log)
.catch(console.error);
removeuser: UserResolvablereason?: string) : Promise<void> (
user: UserResolvable
reason?: string
Unbans a user from the guild.
Examples:
// Unban a user by id (or with a user/guild member object)
await guild.bans.remove('84484653687267328');
resolveban: GuildBanResolvable) : GuildBan | null (
ban: GuildBanResolvable
Resolves a GuildBanResolvable to a GuildBan object.
Overload 1
Overload 2
valueOfCollection<Key, Holds> () :
Inherited from: DataManager