class GuildMemberManager

export class GuildMemberManager extends CachedManager<Snowflake, GuildMember, GuildMemberResolvable>

Manages API methods for GuildMembers and stores their cache.

The cache of this Manager

readonly
client : Client

The client that instantiated this Manager

guild : Guild

The guild this manager belongs to

readonly
holds : Constructable<Holds>

The data structure belonging to this manager.

Inherited from: DataManager

readonly
me : GuildMember | null

The client user as a GuildMember of this guild

add(
options: AddGuildMemberOptions & { fetchWhenExisting: false }
) : Promise<GuildMember | null>

Adds a user to the guild using OAuth2. This method requires the PermissionFlagsBits.CreateInstantInvite permission.

Adds a role to a member.

Bans a user from the guild.

Examples:
// 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.

Edits a member of the guild. The user must be a member of the guild

Fetches member(s) from a guild.

Examples:
// 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);

fetchMe() : Promise<GuildMember>

Fetches the client user as a GuildMember of the guild.

Kicks a user from the guild. The user must be a member of the guild

Examples:
// 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.

Lists up to 1000 members of the guild.

prune(
options: GuildPruneMembersOptions & { dry?: false; count: false }
) : Promise<null>

Prunes members from the guild based on how long they have been inactive.

Examples:
// 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

Removes a role from a member.

Resolves a GuildMemberResolvable to a GuildMember object.

resolveId() : Snowflake

Resolves a GuildMemberResolvable to a member id.

Searches for members in the guild based on a query.

unban(
reason?: string
) : Promise<User | null>

Unbans a user from the guild. Internally calls the remove method.

Examples:
// 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

valueOf() : Collection<Key, Holds>

Inherited from: DataManager