class GuildMember

extends

Base
export class GuildMember extends Base

Represents a member of a guild on Discord.

avatar : string | null

The guild member's avatar hash

readonly
bannable : boolean

Whether this member is bannable by the client user

readonly
client : Client<true>

The client that instantiated this

Inherited from: Base

readonly
communicationDisabledUntil : Date | null

The time this member's timeout will be removed

communicationDisabledUntilTimestamp : number | null

The timestamp this member's timeout will be removed

readonly
displayColor : number

The displayed role color of this member in base 10

readonly
displayHexColor : HexColorString

The displayed role color of this member in hexadecimal

readonly
displayName : string

The nickname of this member, or their user display name if they don't have one

readonly
dmChannel : DMChannel | null

The DM between the client's user and this member

The flags of this member

guild : Guild

The guild that this member is part of

readonly
id : Snowflake

The member's id

readonly
joinedAt : Date | null

The time this member joined the guild

joinedTimestamp : number | null

The timestamp the member joined the guild at

readonly
kickable : boolean

Whether this member is kickable by the client user

readonly
manageable : boolean

Whether the client user is above this user in the hierarchy, according to role position and guild ownership. This is a prerequisite for many moderative actions.

readonly
moderatable : boolean

Whether this member is moderatable by the client user

nickname : string | null

The nickname of this member, if they have one

readonly
partial : false

Whether this GuildMember is a partial

pending : boolean

Whether this member has yet to pass the guild's membership gate

readonly
permissions : Readonly<PermissionsBitField>

The overall set of permissions for this member, taking only roles and owner status into account

readonly
premiumSince : Date | null

The last time this member started boosting the guild

premiumSinceTimestamp : number | null

The last timestamp this member started boosting the guild

readonly
presence : Presence | null

The presence of this guild member

readonly
roles : GuildMemberRoleManager

A manager for the roles belonging to this member

user : User

The user that this guild member instance represents

readonly
voice : VoiceState

The voice state of this member

avatarURL(
options?: ImageURLOptions
) : string | null

A link to the member's guild avatar.

ban(
options?: BanOptions
) : Promise<GuildMember>

Bans this guild member.

Examples:
// Ban a guild member, deleting a week's worth of messages
guildMember.ban({ deleteMessageSeconds: 60 * 60 * 24 * 7, reason: 'They deserved it' })
  .then(console.log)
  .catch(console.error);

createDM(
force?: boolean
) : Promise<DMChannel>

Creates a DM channel between the client and this member.

deleteDM() : Promise<DMChannel>

Deletes any DMs with this member.

disableCommunicationUntil(
communicationDisabledUntil: DateResolvable | null
reason?: string
) : Promise<GuildMember>

Times this guild member out.

Examples:
// Time a guild member out for 5 minutes
guildMember.disableCommunicationUntil(Date.now() + (5 * 60 * 1000), 'They deserved it')
  .then(console.log)
  .catch(console.error);
// Remove the timeout of a guild member
guildMember.disableCommunicationUntil(null)
  .then(member => console.log(`Removed timeout for ${member.displayName}`))
  .catch(console.error);

displayAvatarURL(
options?: ImageURLOptions
) : string

A link to the member's guild avatar if they have one. Otherwise, a link to their displayAvatarURL will be returned.

Edits this member.

equals(
member: GuildMember
) : boolean

Whether this guild member equals another guild member. It compares all properties, so for most comparison it is advisable to just compare member.id === member2.id as it is significantly faster and is often what most users need.

fetch(
force?: boolean
) : Promise<GuildMember>

Fetches this GuildMember.

isCommunicationDisabled() : this is GuildMember & { communicationDisabledUntilTimestamp: number; readonly communicationDisabledUntil: Date; }

Whether this member is currently timed out

kick(
reason?: string
) : Promise<GuildMember>

Kicks this member from the guild.

Returns channel.permissionsFor(guildMember). Returns permissions for a member in a guild channel, taking into account roles and permission overwrites.

Sends a message to this user.

Examples:
// Send a direct message
guildMember.send('Hello!')
  .then(message => console.log(`Sent message: ${message.content} to ${guildMember.displayName}`))
  .catch(console.error);

Sets the flags for this member.

setNickname(
nick: string | null
reason?: string
) : Promise<GuildMember>

Sets the nickname for this member.

Examples:
// Set a nickname for a guild member
guildMember.setNickname('cool nickname', 'Needed a new nickname')
  .then(member => console.log(`Set nickname of ${member.user.username}`))
  .catch(console.error);
// Remove a nickname for a guild member
guildMember.setNickname(null, 'No nicknames allowed!')
  .then(member => console.log(`Removed nickname for ${member.user.username}`))
  .catch(console.error);

timeout(
timeout: number | null
reason?: string
) : Promise<GuildMember>

Times this guild member out.

Examples:
// Time a guild member out for 5 minutes
guildMember.timeout(5 * 60 * 1000, 'They deserved it')
  .then(console.log)
  .catch(console.error);

toJSON() : unknown

toString() : UserMention

When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.

Examples:
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${member}!`);

valueOf() : string