GuildMember
classe · Source
Represents a member of a guild on Discord.
Extends: BaseImplements: TextBasedChannel
Properties
guild
The guild that this member is part of Source
joinedTimestamp
The timestamp the member joined the guild at Source
premiumSinceTimestamp
The last timestamp this member started boosting the guild Source
nickname
The nickname of this member, if they have one Source
pending
Whether this member has yet to pass the guild's membership gate Source
communicationDisabledUntilTimestamp
The timestamp this member's timeout will be removed Source
_roles
The role ids of the member Source
user
The user that this guild member instance represents Source
avatar
The guild member's avatar hash Source
banner
The guild member's banner hash. Source
flags
The flags of this member Source
avatarDecorationData
The member avatar decoration's data Source
collectibles
The member's collectibles Source
deleted
Whether or not the structure has been deleted Source
partial
Whether this GuildMember is a partial Source
roles
A manager for the roles belonging to this member Source
voice
The voice state of this member Source
joinedAt
The time this member joined the guild Source
communicationDisabledUntil
The time this member's timeout will be removed Source
premiumSince
The last time this member started boosting the guild Source
presence
The presence of this guild member Source
displayColor
The displayed color of this member in base 10 Source
displayHexColor
The displayed color of this member in hexadecimal Source
id
The member's id Source
displayName
The nickname of this member, or their user display name if they don't have one Source
permissions
The overall set of permissions for this member, taking only roles and owner status into account Source
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. Source
kickable
Whether this member is kickable by the client user Source
bannable
Whether this member is bannable by the client user Source
moderatable
Whether this member is moderatable by the client user Source
client
The client that instantiated this Source
Methods
avatarDecorationURL
A link to the user's avatar decoration. Returns: stringSource
avatarURL
A link to the member's guild avatar. Parameters
| Name | Type | Description |
|---|---|---|
options? | ImageURLOptions | Options for the Image URL Default: {}. |
Returns: stringSource
bannerURL
A link to the member's banner. Parameters
| Name | Type | Description |
|---|---|---|
options? | ImageURLOptions | Options for the banner URL Default: {}. |
Returns: stringSource
displayAvatarDecorationURL
A link to the member's guild avatar decoration if they have one. Otherwise, a link to their User#avatarDecorationURL will be returned. Returns: stringSource
displayAvatarURL
A link to the member's guild avatar if they have one. Otherwise, a link to their User#displayAvatarURL will be returned. Parameters
| Name | Type | Description |
|---|---|---|
options? | ImageURLOptions | Options for the Image URL Default: {}. |
Returns: stringSource
displayBannerURL
A link to the member's guild banner if they have one. Otherwise, a link to their User#bannerURL will be returned. Parameters
| Name | Type | Description |
|---|---|---|
options? | ImageURLOptions | Options for the image URL Default: {}. |
Returns: stringSource
isCommunicationDisabled
Whether this member is currently timed out Returns: booleanSource
permissionsIn
Returns channel.permissionsFor(guildMember). Returns permissions for a member in a guild channel, taking into account roles and permission overwrites. Parameters
| Name | Type | Description |
|---|---|---|
channel | GuildChannelResolvable | The guild channel to use as context |
Returns: Readonly<Permissions>Source
edit
Edits this member. Parameters
| Name | Type | Description |
|---|---|---|
data | GuildMemberEditData | The data to edit the member with |
reason? | string | Reason for editing this user |
Returns: Promise<GuildMember>Source
setNickname
Sets the nickname for this member. Parameters
| Name | Type | Description |
|---|---|---|
nick | string | The nickname for the guild member, or null if you want to reset their nickname |
reason? | string | Reason for setting the nickname |
Returns: Promise<GuildMember>
// 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);setFlags
Sets the flags for this member. Parameters
| Name | Type | Description |
|---|---|---|
flags | GuildMemberFlagsResolvable | The flags to set |
reason? | string | Reason for setting the flags |
Returns: Promise<GuildMember>Source
createDM
Creates a DM channel between the client and this member. Parameters
| Name | Type | Description |
|---|---|---|
force? | boolean | Whether to skip the cache check and request the API Default: false. |
Returns: Promise<DMChannel>Source
deleteDM
Deletes any DMs with this member. Returns: Promise<DMChannel>Source
kick
Kicks this member from the guild. Parameters
| Name | Type | Description |
|---|---|---|
reason? | string | Reason for kicking user |
Returns: Promise<GuildMember>Source
ban
Bans this guild member. Parameters
| Name | Type | Description |
|---|---|---|
options? | BanOptions | Options for the ban |
Returns: Promise<GuildMember>
// 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);disableCommunicationUntil
Times this guild member out. Parameters
| Name | Type | Description |
|---|---|---|
communicationDisabledUntil | DateResolvable | null | The date or timestamp for the member's communication to be disabled until. Provide null to remove the timeout. |
reason? | string | The reason for this timeout. |
Returns: Promise<GuildMember>
// 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);timeout
Times this guild member out. Parameters
| Name | Type | Description |
|---|---|---|
timeout | number | null | The time in milliseconds for the member's communication to be disabled until. Provide null to remove the timeout. |
reason? | string | The reason for this timeout. |
Returns: Promise<GuildMember>
// Time a guild member out for 5 minutes
guildMember.timeout(5 * 60 * 1000, 'They deserved it')
.then(console.log)
.catch(console.error);fetch
Fetches this GuildMember. Parameters
| Name | Type | Description |
|---|---|---|
force? | boolean | Whether to skip the cache check and request the API Default: true. |
Returns: Promise<GuildMember>Source
equals
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. Parameters
| Name | Type | Description |
|---|---|---|
member | GuildMember | The member to compare with |
Returns: booleanSource
toString
When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object. Returns: string
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${member}!`);setAvatar
Sets the guild avatar of the logged in client. Parameters
| Name | Type | Description |
|---|---|---|
avatar | BufferResolvable | Base64Resolvable | The new avatar |
Returns: Promise<GuildMember>Source
setBanner
Sets the guild banner of the logged in client. Parameters
| Name | Type | Description |
|---|---|---|
banner | BufferResolvable | Base64Resolvable | The new banner |
Returns: Promise<GuildMember>Source
setAboutMe
Set Guild About me Parameters
| Name | Type | Description |
|---|---|---|
bio | string | null | Bio to set Default: null. |
Returns: Promise<GuildMember>Source
send
Sends a message to this user. Parameters
| Name | Type | Description |
|---|---|---|
options | string | MessagePayload | MessageOptions | The options to provide |
Returns: Promise<Message>
// Send a direct message
guildMember.send('Hello!')
.then(message => console.log(`Sent message: ${message.content} to ${guildMember.displayName}`))
.catch(console.error);