Application
extends Part
in package
The OAuth2 application of the bot.
Tags
Table of Contents
Constants
- ACTIVE = 1 << 24
- APPLICATION_AUTO_MODERATION_RULE_CREATE_BADGE = 1 << 6
- APPLICATION_COMMAND_BADGE = 1 << 23
- EMBEDDED = 1 << 17
- GATEWAY_GUILD_MEMBERS = 1 << 14
- GATEWAY_GUILD_MEMBERS_LIMITED = 1 << 15
- GATEWAY_MESSAGE_CONTENT = 1 << 18
- GATEWAY_MESSAGE_CONTENT_LIMITED = 1 << 19
- GATEWAY_PRESENCE = 1 << 12
- GATEWAY_PRESENCE_LIMITED = 1 << 13
- INTEGRATION_TYPE_GUILD_INSTALL = 0
- INTEGRATION_TYPE_USER_INSTALL = 1
- VERIFICATION_PENDING_GUILD_LIMIT = 1 << 16
Properties
- $approximate_guild_count : int|null
- $approximate_user_install_count : int|null
- $bot : User|null
- $bot_public : bool
- $bot_require_code_grant : bool
- $commands : GlobalCommandRepository
- $cover_image : string|null
- $cover_image_hash : string|null
- $created : bool
- Is the part already created in the Discord servers?
- $custom_install_url : string|null
- $description : string
- $flags : int
- $guild_id : string|null
- $icon : string|null
- $icon_hash : string
- $id : string
- $install_params : object|null
- $integration_types : array<string|int, int>|null
- $integration_types_config : array<string|int, object>|null
- $interactions_endpoint_url : string|null
- $invite_url : string
- $name : string
- $owner : User|null
- $primary_sku_id : string|null
- $privacy_policy_url : string|null
- $redirect_uris : array<string|int, string>|null
- $role_connections_verification_url : string|null
- $rpc_origins : array<string|int, string>
- $scriptData : mixed
- Custom script data.
- $slug : string|null
- $tags : array<string|int, string>|null
- $team : object|null
- $terms_of_service_url : string|null
- $verify_key : string
- $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
- Converts the part to a string.
- __unserialize() : void
- 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.
- getCoverImageAttribute() : string|null
- Returns the application cover image.
- getCreatableAttributes() : array<string|int, mixed>
- Returns the attributes needed to create.
- getDiscord() : Discord
- Get the Discord instance that owns this Part.
- getIconAttribute() : string|null
- Returns the application icon.
- getInviteURLAttribute() : string
- Returns the invite URL for the application.
- 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>
- 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.
- 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.
- getBotAttribute() : User|null
- Returns the bot user of the application.
- getCoverImageHashAttribute() : string|null
- Returns the application cover image attribute.
- getIconHashAttribute() : string|null
- Returns the application icon attribute.
- getOwnerAttribute() : User|null
- Returns the owner of the application.
- 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
ACTIVE
public
mixed
ACTIVE
= 1 << 24
APPLICATION_AUTO_MODERATION_RULE_CREATE_BADGE
public
mixed
APPLICATION_AUTO_MODERATION_RULE_CREATE_BADGE
= 1 << 6
APPLICATION_COMMAND_BADGE
public
mixed
APPLICATION_COMMAND_BADGE
= 1 << 23
EMBEDDED
public
mixed
EMBEDDED
= 1 << 17
GATEWAY_GUILD_MEMBERS
public
mixed
GATEWAY_GUILD_MEMBERS
= 1 << 14
GATEWAY_GUILD_MEMBERS_LIMITED
public
mixed
GATEWAY_GUILD_MEMBERS_LIMITED
= 1 << 15
GATEWAY_MESSAGE_CONTENT
public
mixed
GATEWAY_MESSAGE_CONTENT
= 1 << 18
GATEWAY_MESSAGE_CONTENT_LIMITED
public
mixed
GATEWAY_MESSAGE_CONTENT_LIMITED
= 1 << 19
GATEWAY_PRESENCE
public
mixed
GATEWAY_PRESENCE
= 1 << 12
GATEWAY_PRESENCE_LIMITED
public
mixed
GATEWAY_PRESENCE_LIMITED
= 1 << 13
INTEGRATION_TYPE_GUILD_INSTALL
public
mixed
INTEGRATION_TYPE_GUILD_INSTALL
= 0
INTEGRATION_TYPE_USER_INSTALL
public
mixed
INTEGRATION_TYPE_USER_INSTALL
= 1
VERIFICATION_PENDING_GUILD_LIMIT
public
mixed
VERIFICATION_PENDING_GUILD_LIMIT
= 1 << 16
Properties
$approximate_guild_count
public
int|null
$approximate_guild_count
The application's approximate count of the app's guild membership.
$approximate_user_install_count
public
int|null
$approximate_user_install_count
The approximate count of users that have installed the app.
$bot
public
User|null
$bot
The partial user object for the bot user associated with the application.
$bot_public
public
bool
$bot_public
When false only app owner can join the app's bot to guilds.
$bot_require_code_grant
public
bool
$bot_require_code_grant
When true the app's bot will only join upon completion of the full oauth2 code grant flow.
$commands
public
GlobalCommandRepository
$commands
The application global commands.
$cover_image
public
string|null
$cover_image
The application's default rich presence invite cover image URL.
$cover_image_hash
public
string|null
$cover_image_hash
The application's default rich presence invite cover image hash.
$created
Is the part already created in the Discord servers?
public
bool
$created
= false
Whether the part has been created.
$custom_install_url
public
string|null
$custom_install_url
The application's default custom authorization link, if enabled.
$description
public
string
$description
The description of the OAuth application.
$flags
public
int
$flags
The application's public flags.
$guild_id
public
string|null
$guild_id
If this application is a game sold on Discord, this field will be the guild to which it has been linked.
$icon
public
string|null
$icon
The icon URL of the OAuth application.
$icon_hash
public
string
$icon_hash
The icon hash of the OAuth application.
$id
public
string
$id
The client ID of the OAuth application.
$install_params
public
object|null
$install_params
Settings for the application's default in-app authorization link, if enabled.
$integration_types
public
array<string|int, int>|null
$integration_types
$integration_types_config
public
array<string|int, object>|null
$integration_types_config
Default scopes and permissions for each supported installation context. Value for each key is an integration type configuration object.
$interactions_endpoint_url
public
string|null
$interactions_endpoint_url
The interactions endpoint URL for the application.
$invite_url
public
string
$invite_url
The invite URL to invite the bot to a guild.
$name
public
string
$name
The name of the OAuth application.
$owner
public
User|null
$owner
The owner of the OAuth application.
$primary_sku_id
public
string|null
$primary_sku_id
If this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists.
$privacy_policy_url
public
string|null
$privacy_policy_url
The url of the app's privacy policy
$redirect_uris
public
array<string|int, string>|null
$redirect_uris
Array of redirect URIs for the application.
$role_connections_verification_url
public
string|null
$role_connections_verification_url
The application's role connection verification entry point, which when configured will render the app as a verification method in the guild role verification configuration.
$rpc_origins
public
array<string|int, string>
$rpc_origins
An array of RPC origin URLs.
$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.
$slug
public
string|null
$slug
If this application is a game sold on Discord, this field will be the URL slug that links to the store page.
$tags
public
array<string|int, string>|null
$tags
Up to 5 tags describing the content and functionality of the application.
$team
public
object|null
$team
If the application belongs to a team, this will be a list of the members of that team.
$terms_of_service_url
public
string|null
$terms_of_service_url
The url of the app's terms of service.
$verify_key
public
string
$verify_key
The hex encoded key for verification in interactions and the GameSDK's GetTicket.
$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',
'name',
'icon',
'description',
// 'type',
'bot',
// 'is_monetized',
'guild_id',
'bot_public',
'bot_require_code_grant',
'verify_key',
'flags',
// 'hook',
'redirect_uris',
'interactions_endpoint_url',
'role_connections_verification_url',
'owner',
'approximate_guild_count',
'approximate_user_install_count',
// 'interactions_event_types',
// 'interactions_version',
// 'explicit_content_filter',
// 'rpc_application_state',
// 'store_application_state',
// 'verification_state',
// 'integration_public',
// 'integration_require_code_grant',
// 'discoverability_state',
// 'discovery_eligibility_flags',
// 'monetization_state',
// 'monetization_eligibility_flags',
'team',
'integration_types',
'integration_types_config',
'cover_image',
'primary_sku_id',
'slug',
'rpc_origins',
'terms_of_service_url',
'privacy_policy_url',
'custom_install_url',
'install_params',
'tags',
]
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
= ['commands' => \Discord\Repository\Interaction\GlobalCommandRepository::class]
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()
Converts the part to a string.
public
__toString() : string
Tags
Return values
string —A JSON string of attributes.
__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
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
getCoverImageAttribute()
Returns the application cover image.
public
getCoverImageAttribute([string $format = 'webp' ][, int $size = 1024 ]) : string|null
Parameters
- $format : string = 'webp'
-
The image format.
- $size : int = 1024
-
The size of the image.
Return values
string|null —The URL to the application cover image 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
DiscordgetIconAttribute()
Returns the application icon.
public
getIconAttribute([string $format = 'webp' ][, int $size = 1024 ]) : string|null
Parameters
- $format : string = 'webp'
-
The image format.
- $size : int = 1024
-
The size of the image.
Return values
string|null —The URL to the application icon or null.
getInviteURLAttribute()
Returns the invite URL for the application.
public
getInviteURLAttribute([Permission|int $permissions = 0 ]) : string
Parameters
- $permissions : Permission|int = 0
-
Permissions to set.
Return values
string —Invite URL.
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()
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
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.
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.
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
afterConstruct()
Called after the part has been constructed.
protected
afterConstruct() : void
getBotAttribute()
Returns the bot user of the application.
protected
getBotAttribute() : User|null
Return values
User|null —The partial user object for the bot user associated with the application.
getCoverImageHashAttribute()
Returns the application cover image attribute.
protected
getCoverImageHashAttribute() : string|null
Return values
string|null —The application cover image hash or null.
getIconHashAttribute()
Returns the application icon attribute.
protected
getIconHashAttribute() : string|null
Return values
string|null —The application icon hash or null.
getOwnerAttribute()
Returns the owner of the application.
protected
getOwnerAttribute() : User|null
Return values
User|null —Owner of the application.
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.