User
extends Part
in package
A user is a general user that is not attached to a guild.
Tags
Table of Contents
- BOT_HTTP_INTERACTIONS = 1 << 19
- FLAG_ACTIVE_DEVELOPER = 1 < 22
- FLAG_BUG_HUNTER_LEVEL_1 = 1 << 3
- FLAG_BUG_HUNTER_LEVEL_2 = 1 << 14
- FLAG_DISCORD_CERTIFIED_MODERATOR = 1 << 18
- FLAG_DISCORD_EMPLOYEE = 1 << 0
- FLAG_DISCORD_PARTNER = 1 << 1
- FLAG_EARLY_SUPPORTER = 1 << 9
- FLAG_HOUSE_BALANCE = 1 << 8
- FLAG_HOUSE_BRAVERY = 1 << 6
- FLAG_HOUSE_BRILLIANCE = 1 << 7
- FLAG_HYPESQUAD_EVENTS = 1 << 2
- FLAG_SYSTEM = 1 << 12
- FLAG_TEAM_USER = 1 << 10
- FLAG_VERIFIED_BOT = 1 << 16
- FLAG_VERIFIED_BOT_DEVELOPER = 1 << 17
- PREMIUM_NITRO = 2
- PREMIUM_NITRO_BASIC = 3
- PREMIUM_NITRO_CLASSIC = 1
- PREMIUM_NONE = 0
- $accent_color : Array|null
- $avatar : string|null
- $avatar_hash : string|null
- $banner : Array|null
- $banner_hash : string|null
- $bot : bool|null
- $created : bool
- Is the part already created in the Discord servers?
- $discriminator : string
- $displayname : string
- $email : Array|null
- $flags : int|null
- $id : string
- $locale : string|null
- $mfa_enabled : bool|null
- $premium_type : int|null
- $public_flags : int|null
- $scriptData : mixed
- Custom script data.
- $system : bool|null
- $username : string
- $verified : bool|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.
- __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
- broadcastTyping() : ExtendedPromiseInterface
- Broadcasts that you are typing to the channel. Lasts for 5 seconds.
- createdTimestamp() : float
- Returns a timestamp for when a user's account was created.
- ExtendedPromiseInterface() : void
- fetch() : ExtendedPromiseInterface<string|int, self>
- Fetches any missing information about the part from Discord's servers.
- fill() : void
- Fills the parts attributes from an array.
- getAvatarAttribute() : string
- Returns the avatar URL for the client.
- getBannerAttribute() : string|null
- Returns the banner URL for the client.
- getCreatableAttributes() : array<string|int, mixed>
- Returns the attributes needed to create.
- getPrivateChannel() : ExtendedPromiseInterface<string|int, Channel>
- Gets the private channel for the user.
- 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>
- Gets the attributes to pass to repositories.
- getUpdatableAttributes() : array<string|int, mixed>
- Returns the updatable attributes.
- 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.
- 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.
- sendMessage() : ExtendedPromiseInterface<string|int, Message>
- Sends a message to the user.
- serialize() : string|null
- Serializes the data. Used for Serializable.
- unserialize() : void
- Unserializes some data and stores it. Used for Serializable.
- afterConstruct() : void
- Called after the part has been constructed.
- getAvatarHashAttribute() : string|null
- Returns the avatar hash for the client.
- getBannerHashAttribute() : Array|null
- Returns the banner hash for the client.
- getDisplaynameAttribute() : string
- Returns the username with the discriminator.
- checkForMutator() : string|false
- Checks if there is a 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
BOT_HTTP_INTERACTIONS
public
mixed
BOT_HTTP_INTERACTIONS
= 1 << 19
FLAG_ACTIVE_DEVELOPER
public
mixed
FLAG_ACTIVE_DEVELOPER
= 1 < 22
FLAG_BUG_HUNTER_LEVEL_1
public
mixed
FLAG_BUG_HUNTER_LEVEL_1
= 1 << 3
FLAG_BUG_HUNTER_LEVEL_2
public
mixed
FLAG_BUG_HUNTER_LEVEL_2
= 1 << 14
FLAG_DISCORD_CERTIFIED_MODERATOR
public
mixed
FLAG_DISCORD_CERTIFIED_MODERATOR
= 1 << 18
FLAG_DISCORD_EMPLOYEE
public
mixed
FLAG_DISCORD_EMPLOYEE
= 1 << 0
FLAG_DISCORD_PARTNER
public
mixed
FLAG_DISCORD_PARTNER
= 1 << 1
FLAG_EARLY_SUPPORTER
public
mixed
FLAG_EARLY_SUPPORTER
= 1 << 9
FLAG_HOUSE_BALANCE
public
mixed
FLAG_HOUSE_BALANCE
= 1 << 8
FLAG_HOUSE_BRAVERY
public
mixed
FLAG_HOUSE_BRAVERY
= 1 << 6
FLAG_HOUSE_BRILLIANCE
public
mixed
FLAG_HOUSE_BRILLIANCE
= 1 << 7
FLAG_HYPESQUAD_EVENTS
public
mixed
FLAG_HYPESQUAD_EVENTS
= 1 << 2
FLAG_SYSTEM
public
mixed
FLAG_SYSTEM
= 1 << 12
FLAG_TEAM_USER
public
mixed
FLAG_TEAM_USER
= 1 << 10
FLAG_VERIFIED_BOT
public
mixed
FLAG_VERIFIED_BOT
= 1 << 16
FLAG_VERIFIED_BOT_DEVELOPER
public
mixed
FLAG_VERIFIED_BOT_DEVELOPER
= 1 << 17
PREMIUM_NITRO
public
mixed
PREMIUM_NITRO
= 2
PREMIUM_NITRO_BASIC
public
mixed
PREMIUM_NITRO_BASIC
= 3
PREMIUM_NITRO_CLASSIC
public
mixed
PREMIUM_NITRO_CLASSIC
= 1
PREMIUM_NONE
public
mixed
PREMIUM_NONE
= 0
Properties
$accent_color
public
Array|null
$accent_color
The user's banner color encoded as an integer representation of hexadecimal color code.
$avatar
public
string|null
$avatar
The avatar URL of the user.
$avatar_hash
public
string|null
$avatar_hash
The avatar hash of the user.
$banner
public
Array|null
$banner
The banner URL of the user.
$banner_hash
public
string|null
$banner_hash
The banner hash of the user.
$bot
public
bool|null
$bot
Whether the user is a bot.
$created
Is the part already created in the Discord servers?
public
bool
$created
= false
Whether the part has been created.
$discriminator
public
string
$discriminator
The discriminator of the user.
$displayname
public
string
$displayname
The username and discriminator of the user.
public
Array|null
$email
User email.
$flags
public
int|null
$flags
User flags.
$id
public
string
$id
The unique identifier of the user.
$locale
public
string|null
$locale
User locale.
$mfa_enabled
public
bool|null
$mfa_enabled
Whether MFA is enabled.
$premium_type
public
int|null
$premium_type
Type of nitro subscription.
$public_flags
public
int|null
$public_flags
Public flags on the user.
$scriptData
Custom script data.
public
mixed
$scriptData
Used for storing custom information, used by end products.
Tags
$system
public
bool|null
$system
Whether the user is a Discord system user.
$username
public
string
$username
The username of the user.
$verified
public
bool|null
$verified
Whether the user is verified.
$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
= ['id', 'username', 'discriminator', 'avatar', 'bot', 'system', 'mfa_enabled', 'locale', 'verified', 'email', 'flags', 'banner', 'accent_color', 'premium_type', 'public_flags']
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.
Return values
mixed —__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
Return values
void —__toString()
Returns a formatted mention.
public
__toString() : string
Return values
string —A formatted mention.
__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Return values
void —broadcastTyping()
Broadcasts that you are typing to the channel. Lasts for 5 seconds.
public
broadcastTyping() : ExtendedPromiseInterface
Tags
Return values
ExtendedPromiseInterface —createdTimestamp()
Returns a timestamp for when a user's account was created.
public
createdTimestamp() : float
Return values
float —ExtendedPromiseInterface()
public
ExtendedPromiseInterface() : void
<Message> sendMessage(MessageBuilder $builder)
Return values
void —fetch()
Fetches any missing information about the part from Discord's servers.
public
fetch() : ExtendedPromiseInterface<string|int, self>
Tags
Return values
ExtendedPromiseInterface<string|int, self> —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.
Return values
void —getAvatarAttribute()
Returns the avatar URL for the client.
public
getAvatarAttribute([string|null $format = null ][, int $size = 1024 ]) : string
Parameters
- $format : string|null = null
-
The image format.
- $size : int = 1024
-
The size of the image.
Return values
string —The URL to the clients avatar.
getBannerAttribute()
Returns the banner URL for the client.
public
getBannerAttribute([string|null $format = null ][, int $size = 600 ]) : string|null
Parameters
- $format : string|null = null
-
The image format.
- $size : int = 600
-
The size of the image.
Return values
string|null —The URL to the clients banner.
getCreatableAttributes()
Returns the attributes needed to create.
public
getCreatableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPrivateChannel()
Gets the private channel for the user.
public
getPrivateChannel() : ExtendedPromiseInterface<string|int, Channel>
Tags
Return values
ExtendedPromiseInterface<string|int, Channel> —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()
Gets the attributes to pass to repositories.
public
getRepositoryAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —Attributes.
getUpdatableAttributes()
Returns the updatable attributes.
public
getUpdatableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —isPartial()
Whether the part is considered partial i.e. missing information which can be fetched from Discord.
public
isPartial() : bool
Return values
bool —jsonSerialize()
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.
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
Return values
mixed —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
Return values
void —offsetUnset()
Unsets an attribute via key. Used for ArrayAccess.
public
offsetUnset(string $key) : void
Parameters
- $key : string
-
The attribute key.
Return values
void —sendMessage()
Sends a message to the user.
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 ]) : ExtendedPromiseInterface<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
ExtendedPromiseInterface<string|int, Message> —serialize()
Serializes the data. Used for Serializable.
public
serialize() : string|null
Return values
string|null —A string of serialized data.
unserialize()
Unserializes some data and stores it. Used for Serializable.
public
unserialize(string $data) : void
Parameters
- $data : string
-
Some serialized data.
Tags
Return values
void —afterConstruct()
Called after the part has been constructed.
protected
afterConstruct() : void
Return values
void —getAvatarHashAttribute()
Returns the avatar hash for the client.
protected
getAvatarHashAttribute() : string|null
Return values
string|null —The client avatar's hash.
getBannerHashAttribute()
Returns the banner hash for the client.
protected
getBannerHashAttribute() : Array|null
Return values
Array|null —The client banner's hash.
getDisplaynameAttribute()
Returns the username with the discriminator.
protected
getDisplaynameAttribute() : string
Return values
string —Username#Discriminator
checkForMutator()
Checks if there is a mutator present.
private
checkForMutator(string $key, string $type) : string|false
Parameters
- $key : string
-
The attribute name to check.
- $type : string
-
Either get or set.
Return values
string|false —Either a string if it is callable 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.
Return values
void —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.