Member
extends Part
in package
implements
Stringable
A member is a relationship between a user and a guild. It contains user-to-guild specific data like roles.
Tags
Table of Contents
Interfaces
- Stringable
Constants
- FLAGS_BYPASSES_VERIFICATION = 1 << 2
- FLAGS_COMPLETED_ONBOARDING = 1 << 1
- FLAGS_DID_REJOIN = 1 << 0
- FLAGS_STARTED_ONBOARDING = 1 << 3
Properties
- $activities : ExCollectionInterface|array<string|int, Activity>
- $client_status : object
- $communication_disabled_until : Carbon|null
- $created : bool
- Is the part already created in the Discord servers?
- $deaf : bool
- $displayname : string
- $flags : int
- $game : Activity
- $guild : Guild|null
- $guild_id : string|null
- $id : string
- $joined_at : Carbon|null
- $mute : bool
- $pending : bool|null
- $permissions : RolePermission|null
- $premium_since : Carbon|null
- $roles : ExCollectionInterface|array<string|int, Role>
- $scriptData : mixed
- Custom script data.
- $status : string
- $user : User|null
- $username : string|null
- $attributes : array<string|int, mixed>
- The parts attributes.
- $discord : Discord
- The Discord client.
- $factory : Factory
- The factory.
- $fillable : array<string|int, mixed>
- The parts fillable attributes.
- $hidden : array<string|int, mixed>
- Attributes that are hidden from debug info.
- $http : Http
- The HTTP client.
- $repositories : array<string|int, mixed>
- An array of repositories that can exist in a part.
- $repositories_cache : array<string|int, mixed>
- An array of repositories.
- $visible : array<string|int, mixed>
- Attributes which are visible from debug info.
Methods
- __construct() : mixed
- Create a new part instance.
- __debugInfo() : array<string|int, mixed>
- Handles debug calls from var_dump and similar functions.
- __get() : mixed
- Handles dynamic get calls onto the part.
- __serialize() : array<string|int, mixed>
- __set() : void
- Handles dynamic set calls onto the part.
- __toString() : string
- Returns a formatted mention.
- __unserialize() : void
- addRole() : PromiseInterface
- Adds a role to the member.
- ban() : PromiseInterface<string|int, Ban>
- Bans the member. Alias for `$guild->bans->ban()`.
- fetch() : PromiseInterface<string|int, static>
- Fetches any missing information about the part from Discord's servers.
- fill() : void
- Fills the parts attributes from an array.
- getAvatarAttribute() : string|null
- Returns the guild avatar URL for the member.
- getCreatableAttributes() : array<string|int, mixed>
- Returns the attributes needed to create.
- getDiscord() : Discord
- Get the Discord instance that owns this Part.
- getPermissions() : RolePermission|null
- Gets the total permissions of the member.
- getPublicAttributes() : array<string|int, mixed>
- Returns an array of public attributes.
- getRawAttributes() : array<string|int, mixed>
- Returns an array of raw attributes.
- getRepositoryAttributes() : array<string|int, mixed>
- getUpdatableAttributes() : array<string|int, mixed>
- getVoiceChannel() : Channel|null
- Returns the voicechannel of the member.
- isPartial() : bool
- Whether the part is considered partial i.e. missing information which can be fetched from Discord.
- jsonSerialize() : array<string|int, mixed>
- Provides data when the part is encoded into JSON. Used for JsonSerializable.
- kick() : PromiseInterface<string|int, self>
- Alias for `$guild->members->delete()`.
- moveMember() : PromiseInterface<string|int, self>
- Moves the member to another voice channel.
- offsetExists() : bool
- Checks if an attribute exists via key. Used for ArrayAccess.
- offsetGet() : mixed
- Gets an attribute via key. Used for ArrayAccess.
- offsetSet() : void
- Sets an attribute via key. Used for ArrayAccess.
- offsetUnset() : void
- Unsets an attribute via key. Used for ArrayAccess.
- removeRole() : PromiseInterface
- Removes a role from the member.
- sendMessage() : PromiseInterface<string|int, Message>
- sendMessage() : PromiseInterface<string|int, Message>
- Sends a message to the member.
- serialize() : string|null
- Serializes the data. Used for Serializable.
- setBypassesVerification() : PromiseInterface<string|int, self>
- Sets verification bypasses flag on a member.
- setNickname() : PromiseInterface<string|int, self>
- Sets the nickname of the member.
- setRoles() : PromiseInterface<string|int, self>
- Updates member roles.
- timeoutMember() : PromiseInterface<string|int, self>
- Sets timeout on a member.
- unserialize() : void
- Unserializes some data and stores it. Used for Serializable.
- afterConstruct() : void
- Called after the part has been constructed.
- getActivitiesAttribute() : ExCollectionInterface|array<string|int, Activity>
- Gets the activities attribute.
- getAvatarHashAttribute() : string|null
- Returns the guild avatar hash for the member.
- getCommunicationDisabledUntilAttribute() : Carbon|null
- Returns the communication disabled until attribute.
- getDiscriminatorAttribute() : string|null
- Returns the discriminator attribute.
- getDisplaynameAttribute() : string
- Returns the member nickname or display name with optional #discriminator.
- getGameAttribute() : Activity|null
- Gets the game attribute.
- getGuildAttribute() : Guild|null
- Returns the guild attribute.
- getIdAttribute() : string
- Returns the id attribute.
- getJoinedAtAttribute() : Carbon|null
- Returns the joined at attribute.
- getPermissionsAttribute() : RolePermission|null
- Returns the permissions attribute.
- getPremiumSinceAttribute() : Carbon|null
- Returns the premium since attribute.
- getRolesAttribute() : ExCollectionInterface<string|int, Role|null>
- Returns the roles attribute.
- getUserAttribute() : User|null
- Returns the user attribute.
- getUsernameAttribute() : string|null
- Returns the username attribute.
- makeOptionalAttributes() : array<string|int, mixed>
- Return key-value attributes if it has been filled.
- checkForGetMutator() : string|false
- Checks if there is a get mutator present.
- checkForSetMutator() : string|false
- Checks if there is a set mutator present.
- getAttribute() : mixed
- Gets an attribute on the part.
- setAttribute() : void
- Sets an attribute on the part.
- studly() : string
- Converts a string to studlyCase.
Constants
FLAGS_BYPASSES_VERIFICATION
public
mixed
FLAGS_BYPASSES_VERIFICATION
= 1 << 2
FLAGS_COMPLETED_ONBOARDING
public
mixed
FLAGS_COMPLETED_ONBOARDING
= 1 << 1
FLAGS_DID_REJOIN
public
mixed
FLAGS_DID_REJOIN
= 1 << 0
FLAGS_STARTED_ONBOARDING
public
mixed
FLAGS_STARTED_ONBOARDING
= 1 << 3
Properties
$activities
public
ExCollectionInterface|array<string|int, Activity>
$activities
User's current activities.
$client_status
public
object
$client_status
Current client status.
$communication_disabled_until
public
Carbon|null
$communication_disabled_until
When the user's timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out.
$created
Is the part already created in the Discord servers?
public
bool
$created
= false
Whether the part has been created.
$deaf
public
bool
$deaf
Whether the member is deaf.
$displayname read-only
public
string
$displayname
The nickname or display name with optional discriminator of the member.
$flags
public
int
$flags
Guild member flags represented as a bit set, defaults to 0
.
$game read-only
public
Activity
$game
The game the member is playing.
$guild read-only
public
Guild|null
$guild
The guild that the member belongs to.
$guild_id
public
string|null
$guild_id
The unique identifier of the guild that the member belongs to.
$id
public
string
$id
The unique identifier of the member.
$joined_at
public
Carbon|null
$joined_at
A timestamp of when the member joined the guild.
$mute
public
bool
$mute
Whether the member is mute.
$pending
public
bool|null
$pending
Whether the user has not yet passed the guild's Membership Screening requirements.
$permissions
public
RolePermission|null
$permissions
Total permissions of the member in the channel, including overwrites, returned when in the interaction object.
$premium_since
public
Carbon|null
$premium_since
When the user started boosting the server.
$roles
public
ExCollectionInterface|array<string|int, Role>
$roles
A collection of Roles that the member has.
$scriptData
Custom script data.
Relying on this variable with dynamic caching is discouraged.
public
mixed
$scriptData
Used for storing custom information, used by end products.
$status
public
string
$status
The status of the member.
$user
public
User|null
$user
The user part of the member.
$username read-only
public
string|null
$username
The username of the member.
$attributes
The parts attributes.
protected
array<string|int, mixed>
$attributes
= []
The parts attributes and content.
$discord
The Discord client.
protected
Discord
$discord
Client.
$factory
The factory.
protected
Factory
$factory
Factory.
$fillable
The parts fillable attributes.
protected
array<string|int, mixed>
$fillable
= [
'user',
'nick',
'avatar',
'roles',
'joined_at',
'premium_since',
'deaf',
'mute',
'pending',
'permissions',
'communication_disabled_until',
'flags',
// partial
'guild_id',
// @internal
'id',
'status',
'activities',
'client_status',
]
The array of attributes that can be mass-assigned.
$hidden
Attributes that are hidden from debug info.
protected
array<string|int, mixed>
$hidden
= []
Attributes that are hidden from public.
$http
The HTTP client.
protected
Http
$http
Client.
$repositories
An array of repositories that can exist in a part.
protected
array<string|int, mixed>
$repositories
= []
Repositories.
$repositories_cache
An array of repositories.
protected
array<string|int, mixed>
$repositories_cache
= []
$visible
Attributes which are visible from debug info.
protected
array<string|int, mixed>
$visible
= []
Methods
__construct()
Create a new part instance.
public
__construct(Discord $discord[, array<string|int, mixed> $attributes = [] ][, bool $created = false ]) : mixed
Parameters
- $discord : Discord
-
The Discord client.
- $attributes : array<string|int, mixed> = []
-
An array of attributes to build the part.
- $created : bool = false
-
Whether the part has already been created.
__debugInfo()
Handles debug calls from var_dump and similar functions.
public
__debugInfo() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —An array of public attributes.
__get()
Handles dynamic get calls onto the part.
public
__get(string $key) : mixed
Parameters
- $key : string
-
The attributes key.
Tags
Return values
mixed —The value of the attribute.
__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__set()
Handles dynamic set calls onto the part.
public
__set(string $key, mixed $value) : void
Parameters
- $key : string
-
The attributes key.
- $value : mixed
-
The attributes value.
Tags
__toString()
Returns a formatted mention.
public
__toString() : string
Return values
string__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
addRole()
Adds a role to the member.
public
addRole(Role|string $role[, string|null $reason = null ]) : PromiseInterface
Parameters
- $role : Role|string
-
The role to add to the member.
- $reason : string|null = null
-
Reason for Audit Log.
Tags
Return values
PromiseInterfaceban()
Bans the member. Alias for `$guild->bans->ban()`.
public
ban([int|null $daysToDeleteMessages = null ][, string|null $reason = null ]) : PromiseInterface<string|int, Ban>
Parameters
- $daysToDeleteMessages : int|null = null
-
The amount of days to delete messages from.
- $reason : string|null = null
-
Reason of the Ban.
Tags
Return values
PromiseInterface<string|int, Ban>fetch()
Fetches any missing information about the part from Discord's servers.
public
fetch() : PromiseInterface<string|int, static>
Tags
Return values
PromiseInterface<string|int, static>fill()
Fills the parts attributes from an array.
public
fill(array<string|int, mixed> $attributes) : void
Parameters
- $attributes : array<string|int, mixed>
-
An array of attributes to build the part.
Tags
getAvatarAttribute()
Returns the guild avatar URL for the member.
public
getAvatarAttribute([string|null $format = null ][, int $size = 1024 ]) : string|null
Parameters
- $format : string|null = null
-
The image format.
- $size : int = 1024
-
The size of the image.
Return values
string|null —The URL to the member avatar or null.
getCreatableAttributes()
Returns the attributes needed to create.
public
getCreatableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getDiscord()
Get the Discord instance that owns this Part.
public
getDiscord() : Discord
Return values
DiscordgetPermissions()
Gets the total permissions of the member.
public
getPermissions([Channel|Thread|null $channel = null ]) : RolePermission|null
Note that Discord permissions are complex and YOU need to account for the fact that you cannot edit a role higher than your own.
Parameters
- $channel : Channel|Thread|null = null
-
The channel to check its permission overwrites.
null
for just Role.
Tags
Return values
RolePermission|null —null
if permission is failed to be determined.
getPublicAttributes()
Returns an array of public attributes.
public
getPublicAttributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —An array of public attributes.
getRawAttributes()
Returns an array of raw attributes.
public
getRawAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —Raw attributes.
getRepositoryAttributes()
public
getRepositoryAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getUpdatableAttributes()
public
getUpdatableAttributes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getVoiceChannel()
Returns the voicechannel of the member.
public
getVoiceChannel() : Channel|null
Return values
Channel|nullisPartial()
Whether the part is considered partial i.e. missing information which can be fetched from Discord.
public
isPartial() : bool
Return values
booljsonSerialize()
Provides data when the part is encoded into JSON. Used for JsonSerializable.
public
jsonSerialize() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —An array of public attributes.
kick()
Alias for `$guild->members->delete()`.
public
kick([string|null $reason = null ]) : PromiseInterface<string|int, self>
Parameters
- $reason : string|null = null
-
Reason for Audit Log.
Tags
Return values
PromiseInterface<string|int, self>moveMember()
Moves the member to another voice channel.
public
moveMember(mixed $channel[, string|null $reason = null ]) : PromiseInterface<string|int, self>
Parameters
- $channel : mixed
- $reason : string|null = null
-
Reason for Audit Log.
Return values
PromiseInterface<string|int, self>offsetExists()
Checks if an attribute exists via key. Used for ArrayAccess.
public
offsetExists(string $key) : bool
Parameters
- $key : string
-
The attribute key.
Return values
bool —Whether the offset exists.
offsetGet()
Gets an attribute via key. Used for ArrayAccess.
public
offsetGet(string $key) : mixed
Parameters
- $key : string
-
The attribute key.
Tags
Attributes
- #[ReturnTypeWillChange]
offsetSet()
Sets an attribute via key. Used for ArrayAccess.
public
offsetSet(string $key, mixed $value) : void
Parameters
- $key : string
-
The attribute key.
- $value : mixed
-
The attribute value.
Tags
offsetUnset()
Unsets an attribute via key. Used for ArrayAccess.
public
offsetUnset(string $key) : void
Parameters
- $key : string
-
The attribute key.
removeRole()
Removes a role from the member.
public
removeRole(Role|string $role[, string|null $reason = null ]) : PromiseInterface
Parameters
- $role : Role|string
-
The role to remove from the member.
- $reason : string|null = null
-
Reason for Audit Log.
Tags
Return values
PromiseInterfacesendMessage()
public
sendMessage(MessageBuilder $builder) : PromiseInterface<string|int, Message>
Parameters
- $builder : MessageBuilder
Return values
PromiseInterface<string|int, Message>sendMessage()
Sends a message to the member.
public
sendMessage(MessageBuilder|string $message[, bool $tts = false ][, Embed|array<string|int, mixed>|null $embed = null ][, array<string|int, mixed>|null $allowed_mentions = null ][, Message|null $replyTo = null ]) : PromiseInterface<string|int, Message>
Takes a MessageBuilder
or content of the message for the first parameter. If the first parameter
is an instance of MessageBuilder
, the rest of the arguments are disregarded.
Parameters
- $message : MessageBuilder|string
-
The message builder that should be converted into a message, or the string content of the message.
- $tts : bool = false
-
Whether the message is TTS.
- $embed : Embed|array<string|int, mixed>|null = null
-
An embed object or array to send in the message.
- $allowed_mentions : array<string|int, mixed>|null = null
-
Allowed mentions object for the message.
- $replyTo : Message|null = null
-
Sends the message as a reply to the given message instance.
Tags
Return values
PromiseInterface<string|int, Message>serialize()
Serializes the data. Used for Serializable.
public
serialize() : string|null
Return values
string|null —A string of serialized data.
setBypassesVerification()
Sets verification bypasses flag on a member.
public
setBypassesVerification(bool $bypasses_verification[, string|null $reason = null ]) : PromiseInterface<string|int, self>
Parameters
- $bypasses_verification : bool
-
Whether member is exempt from guild verification requirements.
- $reason : string|null = null
-
Reason for Audit Log.
Tags
Return values
PromiseInterface<string|int, self>setNickname()
Sets the nickname of the member.
public
setNickname([string|null|null $nick = null ][, string|null $reason = null ]) : PromiseInterface<string|int, self>
Parameters
- $nick : string|null|null = null
-
The nickname of the member.
- $reason : string|null = null
-
Reason for Audit Log.
Tags
Return values
PromiseInterface<string|int, self>setRoles()
Updates member roles.
public
setRoles(ExCollectionInterface|array<string|int, Role>|array<string|int, string> $roles[, string|null $reason = null ]) : PromiseInterface<string|int, self>
Parameters
- $roles : ExCollectionInterface|array<string|int, Role>|array<string|int, string>
-
The roles to set to the member.
- $reason : string|null = null
-
Reason for Audit Log.
Tags
Return values
PromiseInterface<string|int, self>timeoutMember()
Sets timeout on a member.
public
timeoutMember(Carbon|null $communication_disabled_until[, string|null $reason = null ]) : PromiseInterface<string|int, self>
Parameters
- $communication_disabled_until : Carbon|null
-
When the user's timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out.
- $reason : string|null = null
-
Reason for Audit Log.
Tags
Return values
PromiseInterface<string|int, self>unserialize()
Unserializes some data and stores it. Used for Serializable.
public
unserialize(string $data) : void
Parameters
- $data : string
-
Some serialized data.
Tags
afterConstruct()
Called after the part has been constructed.
protected
afterConstruct() : void
getActivitiesAttribute()
Gets the activities attribute.
protected
getActivitiesAttribute() : ExCollectionInterface|array<string|int, Activity>
Return values
ExCollectionInterface|array<string|int, Activity>getAvatarHashAttribute()
Returns the guild avatar hash for the member.
protected
getAvatarHashAttribute() : string|null
Tags
Return values
string|nullgetCommunicationDisabledUntilAttribute()
Returns the communication disabled until attribute.
protected
getCommunicationDisabledUntilAttribute() : Carbon|null
Tags
Return values
Carbon|nullgetDiscriminatorAttribute()
Returns the discriminator attribute.
protected
getDiscriminatorAttribute() : string|null
Use $member->user->discriminator
Return values
string|null —The discriminator of the member.
getDisplaynameAttribute()
Returns the member nickname or display name with optional #discriminator.
protected
getDisplaynameAttribute() : string
Return values
string —Either nick or global_name or username with optional #discriminator.
getGameAttribute()
Gets the game attribute.
protected
getGameAttribute() : Activity|null
Polyfill for the first activity.
Return values
Activity|nullgetGuildAttribute()
Returns the guild attribute.
protected
getGuildAttribute() : Guild|null
Return values
Guild|null —The guild.
getIdAttribute()
Returns the id attribute.
protected
getIdAttribute() : string
Return values
string —The user ID of the member.
getJoinedAtAttribute()
Returns the joined at attribute.
protected
getJoinedAtAttribute() : Carbon|null
Tags
Return values
Carbon|null —The timestamp from when the member joined.
getPermissionsAttribute()
Returns the permissions attribute.
protected
getPermissionsAttribute() : RolePermission|null
This is only available from Interaction, use Member::getPermissions() for normal permissions.
Tags
Return values
RolePermission|null —The total calculated permissions, only available from Interaction.
getPremiumSinceAttribute()
Returns the premium since attribute.
protected
getPremiumSinceAttribute() : Carbon|null
Tags
Return values
Carbon|nullgetRolesAttribute()
Returns the roles attribute.
protected
getRolesAttribute() : ExCollectionInterface<string|int, Role|null>
Return values
ExCollectionInterface<string|int, Role|null> —A collection of roles the member is in. null role only contains ID in the collection.
getUserAttribute()
Returns the user attribute.
protected
getUserAttribute() : User|null
Return values
User|null —The user that owns the member.
getUsernameAttribute()
Returns the username attribute.
protected
getUsernameAttribute() : string|null
Return values
string|null —The username of the member.
makeOptionalAttributes()
Return key-value attributes if it has been filled.
protected
makeOptionalAttributes(array<string|int, mixed> $attributes) : array<string|int, mixed>
To be used with fields marked "optional?" from the API.
Parameters
- $attributes : array<string|int, mixed>
-
Names of optional attribute
Return values
array<string|int, mixed>checkForGetMutator()
Checks if there is a get mutator present.
private
checkForGetMutator(string $key) : string|false
Parameters
- $key : string
-
The attribute name to check.
Tags
Return values
string|false —Either a string if it is a method or false.
checkForSetMutator()
Checks if there is a set mutator present.
private
checkForSetMutator(string $key) : string|false
Parameters
- $key : string
-
The attribute name to check.
Tags
Return values
string|false —Either a string if it is a method or false.
getAttribute()
Gets an attribute on the part.
private
getAttribute(string $key) : mixed
Parameters
- $key : string
-
The key to the attribute.
Tags
Return values
mixed —Either the attribute if it exists or void.
setAttribute()
Sets an attribute on the part.
private
setAttribute(string $key, mixed $value) : void
Parameters
- $key : string
-
The key to the attribute.
- $value : mixed
-
The value of the attribute.
studly()
Converts a string to studlyCase.
private
static studly(string $string) : string
This is a port of updated Laravel's implementation, a non-regex with static cache. The Discord\studly() is kept due to unintended bug and we do not want to introduce BC by replacing it. This method is private static as we may move it outside this class in future.
Parameters
- $string : string
-
The string to convert.