class GuildMemberManager
extends
CachedManager<Snowflake, GuildMember, GuildMemberResolvable>export class GuildMemberManager extends CachedManager<Snowflake, GuildMember, GuildMemberResolvable>
Manages API methods for GuildMembers 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
readonlyGuildMember | null me :
The client user as a GuildMember of this guild
adduser: UserResolvableoptions: AddGuildMemberOptions & { fetchWhenExisting: false }) : Promise<GuildMember | null> (
Adds a user to the guild using OAuth2. This method requires the PermissionFlagsBits.CreateInstantInvite permission.
addRoleoptions: AddOrRemoveGuildMemberRoleOptions) : Promise<GuildMember | User | Snowflake> (
Adds a role to a member.
banuser: UserResolvableoptions?: BanOptions) : Promise<GuildMember | User | Snowflake> (
Bans a user from the guild.
// Ban a user by id (or with a user/guild member object)
guild.members.ban('84484653687267328')
.then(banInfo => console.log(`Banned ${banInfo.user?.tag ?? banInfo.tag ?? banInfo}`))
.catch(console.error);
Returns: Result object will be resolved as specifically as possible. If the GuildMember cannot be resolved, the User will instead be attempted to be resolved. If that also cannot be resolved, the user id will be the result. Internally calls the GuildBanManager#create method.
edituser: UserResolvableoptions: GuildMemberEditOptions) : Promise<GuildMember> (
Edits a member of the guild. The user must be a member of the guild
fetchoptions: UserResolvable | FetchMemberOptions | (FetchMembersOptions & { user: UserResolvable })) : Promise<GuildMember> (
Fetches member(s) from a guild.
// Fetch all members from a guild
guild.members.fetch()
.then(console.log)
.catch(console.error);
// Fetch a single member
guild.members.fetch('66564597481480192')
.then(console.log)
.catch(console.error);
// Fetch a single member without checking cache
guild.members.fetch({ user, force: true })
.then(console.log)
.catch(console.error)
// Fetch a single member without caching
guild.members.fetch({ user, cache: false })
.then(console.log)
.catch(console.error);
// Fetch by an array of users including their presences
guild.members.fetch({ user: ['66564597481480192', '191615925336670208'], withPresences: true })
.then(console.log)
.catch(console.error);
// Fetch by query
guild.members.fetch({ query: 'hydra', limit: 1 })
.then(console.log)
.catch(console.error);
fetchMeoptions?: BaseFetchOptions) : Promise<GuildMember> (
Fetches the client user as a GuildMember of the guild.
kickuser: UserResolvablereason?: string) : Promise<GuildMember | User | Snowflake> (
Kicks a user from the guild. The user must be a member of the guild
// Kick a user by id (or with a user/guild member object)
guild.members.kick('84484653687267328')
.then(kickInfo => console.log(`Kicked ${kickInfo.user?.tag ?? kickInfo.tag ?? kickInfo}`))
.catch(console.error);
Returns: Result object will be resolved as specifically as possible. If the GuildMember cannot be resolved, the User will instead be attempted to be resolved. If that also cannot be resolved, the user's id will be the result.
listoptions?: GuildListMembersOptions) : Promise<Collection<Snowflake, GuildMember>> (
Lists up to 1000 members of the guild.
pruneoptions: GuildPruneMembersOptions & { dry?: false; count: false }) : Promise<null> (
Prunes members from the guild based on how long they have been inactive.
// See how many members will be pruned
guild.members.prune({ dry: true })
.then(pruned => console.log(`This will prune ${pruned} people!`))
.catch(console.error);
// Actually prune the members
guild.members.prune({ days: 1, reason: 'too many people!' })
.then(pruned => console.log(`I just pruned ${pruned} people!`))
.catch(console.error);
// Include members with a specified role
guild.members.prune({ days: 7, roles: ['657259391652855808'] })
.then(pruned => console.log(`I just pruned ${pruned} people!`))
.catch(console.error);
Returns: The number of members that were/will be kicked
removeRoleoptions: AddOrRemoveGuildMemberRoleOptions) : Promise<GuildMember | User | Snowflake> (
Removes a role from a member.
resolvemember: GuildMemberResolvable) : GuildMember (
Resolves a GuildMemberResolvable to a GuildMember object.
resolveIdmember: GuildMemberResolvable) : Snowflake (
Resolves a GuildMemberResolvable to a member id.
searchoptions: GuildSearchMembersOptions) : Promise<Collection<Snowflake, GuildMember>> (
Searches for members in the guild based on a query.
unbanuser: UserResolvablereason?: string) : Promise<User | null> (
Unbans a user from the guild. Internally calls the remove method.
// Unban a user by id (or with a user/guild member object)
guild.members.unban('84484653687267328')
.then(user => console.log(`Unbanned ${user.username} from ${guild.name}`))
.catch(console.error);
Returns: The user that was unbanned
valueOfCollection<Key, Holds> () :
Inherited from: DataManager