GuildMember

export class GuildMember extends Base
export class GuildMember extends Base
Represents a member of a guild on Discord.

Extends

Base
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
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
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
A manager for the roles belonging to this member
user:User
The user that this guild member instance represents
Readonly
The voice state of this member
avatarURL(options?):string | null
A link to the member's guild avatar.
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
ban(options?):Promise<GuildMember>
Bans this guild member.
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsBanOptionsYesOptions for the ban
bannerURL(options?):string | null
A link to the member's banner.
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the banner URL
createDM(force?):Promise<DMChannel>
Creates a DM channel between the client and this member.
NameTypeOptionalDescription
forcebooleanYesWhether to skip the cache check and request the API
deleteDM():Promise<DMChannel>
Deletes any DMs with this member.
disableCommunicationUntil(communicationDisabledUntil, reason?):Promise<GuildMember>
Times this guild member out.
Example
// Time a guild member out for 5 minutes
guildMember.disableCommunicationUntil(Date.now() + (5 * 60 * 1000), 'They deserved it')
.then(console.log)
.catch(console.error);
// Time a guild member out for 5 minutes
guildMember.disableCommunicationUntil(Date.now() + (5 * 60 * 1000), 'They deserved it')
.then(console.log)
.catch(console.error);
Example
// Remove the timeout of a guild member
guildMember.disableCommunicationUntil(null)
.then(member => console.log(`Removed timeout for ${member.displayName}`))
.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);
NameTypeOptionalDescription
communicationDisabledUntilDateResolvable | nullNoThe date or timestamp for the member's communication to be disabled until. Provide null to remove the timeout.
reasonstringYesThe reason for this timeout.
displayAvatarURL(options?):string
A link to the member's guild avatar if they have one. Otherwise, a link to their will be returned.
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
displayBannerURL(options?):string | null
A link to the member's guild banner if they have one. Otherwise, a link to their will be returned.
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
edit(options):Promise<GuildMember>
Edits this member.
NameTypeOptionalDescription
optionsGuildMemberEditOptionsNoThe options to provide
equals(member):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.
NameTypeOptionalDescription
memberGuildMemberNoThe member to compare with
fetch(force?):Promise<GuildMember>
Fetches this GuildMember.
NameTypeOptionalDescription
forcebooleanYesWhether to skip the cache check and request the API
isCommunicationDisabled():this is GuildMember & { communicationDisabledUntilTimestamp: number; readonly communicationDisabledUntil: Date; }
Whether this member is currently timed out
kick(reason?):Promise<GuildMember>
Kicks this member from the guild.
NameTypeOptionalDescription
reasonstringYesReason for kicking user
permissionsIn(channel):Readonly<PermissionsBitField>
Returns channel.permissionsFor(guildMember). Returns permissions for a member in a guild channel, taking into account roles and permission overwrites.
NameTypeOptionalDescription
channelGuildChannelResolvableNoThe guild channel to use as context
send(options):Promise<Message>
Sends a message to this user.
Example
// Send a direct message
guildMember.send('Hello!')
.then(message => console.log(`Sent message: ${message.content} to ${guildMember.displayName}`))
.catch(console.error);
// Send a direct message
guildMember.send('Hello!')
.then(message => console.log(`Sent message: ${message.content} to ${guildMember.displayName}`))
.catch(console.error);
NameTypeOptionalDescription
optionsstring | MessagePayload | MessageCreateOptionsNoThe options to provide
setFlags(flags, reason?):Promise<GuildMember>
Sets the flags for this member.
NameTypeOptionalDescription
flagsGuildMemberFlagsResolvableNoThe flags to set
reasonstringYesReason for setting the flags
setNickname(nick, reason?):Promise<GuildMember>
Sets the nickname for this member.
Example
// 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);
// 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);
Example
// 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);
// 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);
NameTypeOptionalDescription
nickstring | nullNoThe nickname for the guild member, or null if you want to reset their nickname
reasonstringYesReason for setting the nickname
timeout(timeout, reason?):Promise<GuildMember>
Times this guild member out.
Example
// Time a guild member out for 5 minutes
guildMember.timeout(5 * 60 * 1000, 'They deserved it')
.then(console.log)
.catch(console.error);
// Time a guild member out for 5 minutes
guildMember.timeout(5 * 60 * 1000, 'They deserved it')
.then(console.log)
.catch(console.error);
NameTypeOptionalDescription
timeoutnumber | nullNoThe duration in milliseconds for the member's communication to be disabled. Provide null to remove the timeout.
reasonstringYesThe reason for this timeout.
toJSON():unknown
toString():UserMention
When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
Example
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${member}!`);
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${member}!`);
valueOf():string
send(options):Promise<Message<InGuild>>
NameTypeOptionalDescription
optionsstring | MessagePayload | MessageCreateOptionsNoNone
Inherited from PartialTextBasedChannelFields