Constructor
new GuildMember(client, data, guild)
Parameters:
Name | Type | Description |
---|---|---|
client |
Client | The instantiating client |
data |
Object | The data for the guild member |
guild |
Guild | The guild the member is part of |
- Implements:
- Source:
Extends
Members
(readonly) bannable :boolean
Whether this member is bannable by the client user
Type:
- boolean
- Source:
(readonly) client :Client
The client that instantiated this
Type:
- Overrides:
- Source:
deleted :boolean
Whether the member has been removed from the guild
Type:
- boolean
- Source:
(readonly) displayColor :number
The displayed color of this member in base 10
Type:
- number
- Source:
(readonly) displayHexColor :string
The displayed color of this member in hexadecimal
Type:
- string
- Source:
(readonly, nullable) displayName :string
The nickname of this member, or their username if they don't have one
Type:
- string
- Source:
guild :Guild
The guild that this member is part of
Type:
- Source:
(readonly) id :Snowflake
The ID of this member
Type:
- Source:
(readonly, nullable) joinedAt :Date
The time this member joined the guild
Type:
- Date
- Source:
(nullable) joinedTimestamp :number
The timestamp the member joined the guild at
Type:
- number
- Source:
(readonly) kickable :boolean
Whether this member is kickable by the client user
Type:
- boolean
- Source:
(readonly, nullable) lastMessage :Message
The Message object of the last message sent by the member in their guild, if one was sent
Type:
- Implements:
- Source:
(nullable) lastMessageChannelID :Snowflake
The ID of the channel for the last message sent by the member in their guild, if one was sent
Type:
- Source:
(nullable) lastMessageID :Snowflake
The ID of the last message sent by the member in their guild, if one was sent
Type:
- Source:
(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.
Type:
- boolean
- Source:
(nullable) nickname :string
The nickname of this member, if they have one
Type:
- string
- Source:
(readonly) partial :boolean
Whether this GuildMember is a partial
Type:
- boolean
- Source:
(readonly) permissions :Readonly.<Permissions>
The overall set of permissions for this member, taking only roles into account
Type:
- Readonly.<Permissions>
- Source:
(readonly, nullable) premiumSince :Date
The time of when the member used their Nitro boost on the guild, if it was used
Type:
- Date
- Source:
(nullable) premiumSinceTimestamp :number
The timestamp of when the member used their Nitro boost on the guild, if it was used
Type:
- number
- Source:
(readonly) presence :Presence
The presence of this guild member
Type:
- Source:
(readonly) roles :GuildMemberRoleManager
A manager for the roles belonging to this member
Type:
- Source:
user :User
The user that this guild member instance represents
Type:
- Source:
(readonly) voice :VoiceState
The voice state of this member
Type:
- Source:
Methods
ban(optionsopt) → {Promise.<GuildMember>}
Bans this guild member.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Options for the ban
Properties
|
- Source:
Returns:
- Type
- Promise.<GuildMember>
Example
// ban a guild member
guildMember.ban({ days: 7, reason: 'They deserved it' })
.then(console.log)
.catch(console.error);
createDM() → {Promise.<DMChannel>}
Creates a DM channel between the client and this member.
- Source:
Returns:
- Type
- Promise.<DMChannel>
deleteDM() → {Promise.<DMChannel>}
Deletes any DMs with this member.
- Source:
Returns:
- Type
- Promise.<DMChannel>
(async) edit(data, reasonopt) → {Promise.<GuildMember>}
Edits this member.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
GuildMemberEditData | The data to edit the member with | |
reason |
string |
<optional> |
Reason for editing this user |
- Source:
Returns:
- Type
- Promise.<GuildMember>
fetch(forceopt) → {Promise.<GuildMember>}
Fetches this GuildMember.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
force |
boolean |
<optional> |
false | Whether to skip the cache check and request the API |
- Source:
Returns:
- Type
- Promise.<GuildMember>
hasPermission(permission, optionsopt) → {boolean}
Checks if any of this member's roles have a permission.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
permission |
PermissionResolvable | Permission(s) to check for | ||||||||||||||||
options |
Object |
<optional> |
Options
Properties
|
- Source:
Returns:
- Type
- boolean
kick(reasonopt) → {Promise.<GuildMember>}
Kicks this member from the guild.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
reason |
string |
<optional> |
Reason for kicking user |
- Source:
Returns:
- Type
- Promise.<GuildMember>
permissionsIn(channel) → {Readonly.<Permissions>}
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 |
ChannelResolvable | The guild channel to use as context |
- Source:
Returns:
- Type
- Readonly.<Permissions>
(async) send(contentopt, optionsopt) → {Promise.<(Message|Array.<Message>)>}
Sends a message to this channel.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
content |
StringResolvable | APIMessage |
<optional> |
'' | The content to send |
options |
MessageOptions | MessageAdditions |
<optional> |
{} | The options to provide |
- Implements:
- Source:
Returns:
Examples
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
// Send a remote file
channel.send({
files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
.then(console.log)
.catch(console.error);
// Send a local file
channel.send({
files: [{
attachment: 'entire/path/to/file.jpg',
name: 'file.jpg'
}]
})
.then(console.log)
.catch(console.error);
// Send an embed with a local image inside
channel.send('This is an embed', {
embed: {
thumbnail: {
url: 'attachment://file.jpg'
}
},
files: [{
attachment: 'entire/path/to/file.jpg',
name: 'file.jpg'
}]
})
.then(console.log)
.catch(console.error);
setNickname(nick, reasonopt) → {Promise.<GuildMember>}
Sets the nickname for this member.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
nick |
string | The nickname for the guild member | |
reason |
string |
<optional> |
Reason for setting the nickname |
- Source:
Returns:
- Type
- Promise.<GuildMember>
toString() → {string}
When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
- Source:
Returns:
- Type
- string
Example
// Logs: Hello from <@123456789012345678>!
console.log(`Hello from ${member}!`);