class GuildMember
extends
PartialTextBasedChannel(Base)export class GuildMember extends PartialTextBasedChannel(Base)
Represents a member of a guild on Discord.
readonlyboolean bannable :
Whether this member is bannable by the client user
readonlyClient client :
The client that instantiated this
The timestamp this member's timeout will be removed
readonlynumber displayColor :
The displayed role color of this member in base 10
readonlyHexColorString displayHexColor :
The displayed role color of this member in hexadecimal
readonlystring displayName :
The nickname of this member, or their user display name if they don't have one
Readonly<GuildMemberFlagsBitField> flags :
The flags of this member
Guild guild :
The guild that this member is part of
readonlySnowflake id :
The member's id
readonlyboolean kickable :
Whether this member is kickable by the client user
readonlyboolean manageable :
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.
readonlyboolean moderatable :
Whether this member is moderatable by the client user
boolean pending :
Whether this member has yet to pass the guild's membership gate
readonlyReadonly<PermissionsBitField> permissions :
The overall set of permissions for this member, taking only roles and owner status into account
readonlyGuildMemberRoleManager roles :
A manager for the roles belonging to this member
User user :
The user that this guild member instance represents
readonlyVoiceState voice :
The voice state of this member
avatarURLoptions?: ImageURLOptions) : string | null (
A link to the member's guild avatar.
banoptions?: BanOptions) : Promise<GuildMember> (
Bans this guild member.
// 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);
Creates a DM channel between the client and this member.
disableCommunicationUntilcommunicationDisabledUntil: DateResolvable | nullreason?: string) : Promise<GuildMember> (
Times this guild member out.
// 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);
displayAvatarURLoptions?: ImageURLOptions) : string (
A link to the member's guild avatar if they have one. Otherwise, a link to their displayAvatarURL will be returned.
editoptions: GuildMemberEditOptions) : Promise<GuildMember> (
Edits this member.
equalsmember: 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.
fetchforce?: boolean) : Promise<GuildMember> (
Fetches this GuildMember.
isCommunicationDisabledthis is GuildMember & { communicationDisabledUntilTimestamp: number; readonly communicationDisabledUntil: Date; } () :
Whether this member is currently timed out
kickreason?: string) : Promise<GuildMember> (
Kicks this member from the guild.
permissionsInchannel: GuildChannelResolvable) : Readonly<PermissionsBitField> (
Returns channel.permissionsFor(guildMember)
. Returns permissions for a member in a guild channel, taking into account roles and permission overwrites.
sendoptions: string | MessagePayload | MessageCreateOptions) : Promise<Message> (
Sends a message to this user.
// Send a direct message
guildMember.send('Hello!')
.then(message => console.log(`Sent message: ${message.content} to ${guildMember.displayName}`))
.catch(console.error);
setFlagsflags: GuildMemberFlagsResolvablereason?: string) : Promise<GuildMember> (
Sets the flags for this member.
setNickname) : Promise<GuildMember> (
Sets the nickname for this member.
// 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) : Promise<GuildMember> (
Times this guild member out.
// Time a guild member out for 5 minutes
guildMember.timeout(5 * 60 * 1000, 'They deserved it')
.then(console.log)
.catch(console.error);
toJSONunknown () :
toStringUserMention () :
When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${member}!`);