RolePermission
extends Permission
in package
Represents a set of permissions for a given role.
Tags
Table of Contents
- ALL_PERMISSIONS = ['create_instant_invite' => 0, 'manage_channels' => 4, 'view_channel' => 10, 'mention_everyone' => 17, 'manage_roles' => 28]
- Array of permissions for all roles.
- ROLE_PERMISSIONS = ['kick_members' => 1, 'ban_members' => 2, 'administrator' => 3, 'manage_guild' => 5, 'view_audit_log' => 7, 'view_guild_insights' => 19, 'change_nickname' => 26, 'manage_nicknames' => 27, 'manage_emojis_and_stickers' => 30, 'moderate_members' => 40, 'view_creator_monetization_analytics' => 41]
- Array of permissions that can only be applied to roles.
- STAGE_PERMISSIONS = ['connect' => 20, 'mute_members' => 22, 'deafen_members' => 23, 'move_members' => 24, 'request_to_speak' => 32, 'manage_events' => 33]
- Array of permissions that only apply to stage channels.
- TEXT_PERMISSIONS = ['add_reactions' => 6, 'send_messages' => 11, 'send_tts_messages' => 12, 'manage_messages' => 13, 'embed_links' => 14, 'attach_files' => 15, 'read_message_history' => 16, 'use_external_emojis' => 18, 'manage_webhooks' => 29, 'use_application_commands' => 31, 'manage_threads' => 34, 'create_public_threads' => 35, 'create_private_threads' => 36, 'use_external_stickers' => 37, 'send_messages_in_threads' => 38]
- Array of permissions that only apply to text channels.
- VOICE_PERMISSIONS = ['add_reactions' => 6, 'priority_speaker' => 8, 'stream' => 9, 'send_messages' => 11, 'send_tts_messages' => 12, 'manage_messages' => 13, 'embed_links' => 14, 'attach_files' => 15, 'read_message_history' => 16, 'use_external_emojis' => 18, 'connect' => 20, 'speak' => 21, 'mute_members' => 22, 'deafen_members' => 23, 'move_members' => 24, 'use_vad' => 25, 'manage_webhooks' => 29, 'manage_events' => 33, 'use_external_stickers' => 37, 'use_embedded_activities' => 39]
- Array of permissions that only apply to voice channels.
- $add_reactions : bool
- $administrator : bool
- $attach_files : bool
- $ban_members : bool
- $bitwise : int|string
- $change_nickname : bool
- $connect : bool
- $create_instant_invite : bool
- $create_private_threads : bool
- $create_public_threads : bool
- $created : bool
- Is the part already created in the Discord servers?
- $deafen_members : bool
- $embed_links : bool
- $kick_members : bool
- $manage_channels : bool
- $manage_emojis_and_stickers : bool
- $manage_events : bool
- $manage_guild : bool
- $manage_messages : bool
- $manage_nicknames : bool
- $manage_roles : bool
- $manage_threads : bool
- $manage_webhooks : bool
- $mention_everyone : bool
- $moderate_members : bool
- $move_members : bool
- $mute_members : bool
- $priority_speaker : bool
- $read_message_history : bool
- $request_to_speak : bool
- $scriptData : mixed
- Custom script data.
- $send_messages : bool
- $send_messages_in_threads : bool
- $send_tts_messages : bool
- $speak : bool
- $stream : bool
- $use_application_commands : bool
- $use_embedded_activities : bool
- $use_external_emojis : bool
- $use_external_stickers : bool
- $use_vad : bool
- $view_audit_log : bool
- $view_channel : bool
- $view_creator_monetization_analytics : bool
- $view_guild_insights : bool
- $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.
- $permissions : array<string|int, mixed>
- Array of permissions.
- __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() : ExtendedPromiseInterface<string|int, self>
- Fetches any missing information about the part from Discord's servers.
- fill() : void
- Fills the parts attributes from an array.
- getCreatableAttributes() : array<string|int, mixed>
- Returns the attributes needed to create.
- getPermissions() : array<string|int, mixed>
- Returns an array of extra permissions.
- 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.
- 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.
- getBitwiseAttribute() : int|string
- Gets the bitwise attribute of the permission.
- setBitwiseAttribute() : mixed
- Sets the bitwise attribute of the permission.
- 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
ALL_PERMISSIONS
Array of permissions for all roles.
public
array<string|int, mixed>
ALL_PERMISSIONS
= ['create_instant_invite' => 0, 'manage_channels' => 4, 'view_channel' => 10, 'mention_everyone' => 17, 'manage_roles' => 28]
i.e. indicated T,V,S in documentation.
ROLE_PERMISSIONS
Array of permissions that can only be applied to roles.
public
array<string|int, mixed>
ROLE_PERMISSIONS
= ['kick_members' => 1, 'ban_members' => 2, 'administrator' => 3, 'manage_guild' => 5, 'view_audit_log' => 7, 'view_guild_insights' => 19, 'change_nickname' => 26, 'manage_nicknames' => 27, 'manage_emojis_and_stickers' => 30, 'moderate_members' => 40, 'view_creator_monetization_analytics' => 41]
i.e. indicated empty in documentation.
STAGE_PERMISSIONS
Array of permissions that only apply to stage channels.
public
array<string|int, mixed>
STAGE_PERMISSIONS
= ['connect' => 20, 'mute_members' => 22, 'deafen_members' => 23, 'move_members' => 24, 'request_to_speak' => 32, 'manage_events' => 33]
i.e. indicated S in documentation.
TEXT_PERMISSIONS
Array of permissions that only apply to text channels.
public
array<string|int, mixed>
TEXT_PERMISSIONS
= ['add_reactions' => 6, 'send_messages' => 11, 'send_tts_messages' => 12, 'manage_messages' => 13, 'embed_links' => 14, 'attach_files' => 15, 'read_message_history' => 16, 'use_external_emojis' => 18, 'manage_webhooks' => 29, 'use_application_commands' => 31, 'manage_threads' => 34, 'create_public_threads' => 35, 'create_private_threads' => 36, 'use_external_stickers' => 37, 'send_messages_in_threads' => 38]
i.e. indicated T in documentation.
VOICE_PERMISSIONS
Array of permissions that only apply to voice channels.
public
array<string|int, mixed>
VOICE_PERMISSIONS
= ['add_reactions' => 6, 'priority_speaker' => 8, 'stream' => 9, 'send_messages' => 11, 'send_tts_messages' => 12, 'manage_messages' => 13, 'embed_links' => 14, 'attach_files' => 15, 'read_message_history' => 16, 'use_external_emojis' => 18, 'connect' => 20, 'speak' => 21, 'mute_members' => 22, 'deafen_members' => 23, 'move_members' => 24, 'use_vad' => 25, 'manage_webhooks' => 29, 'manage_events' => 33, 'use_external_stickers' => 37, 'use_embedded_activities' => 39]
i.e. indicated V in documentation.
Properties
$add_reactions
public
bool
$add_reactions
$administrator
public
bool
$administrator
$attach_files
public
bool
$attach_files
$ban_members
public
bool
$ban_members
$bitwise
public
int|string
$bitwise
$change_nickname
public
bool
$change_nickname
$connect
public
bool
$connect
$create_instant_invite
public
bool
$create_instant_invite
$create_private_threads
public
bool
$create_private_threads
$create_public_threads
public
bool
$create_public_threads
$created
Is the part already created in the Discord servers?
public
bool
$created
= false
Whether the part has been created.
$deafen_members
public
bool
$deafen_members
$embed_links
public
bool
$embed_links
$kick_members
public
bool
$kick_members
$manage_channels
public
bool
$manage_channels
$manage_emojis_and_stickers
public
bool
$manage_emojis_and_stickers
$manage_events
public
bool
$manage_events
$manage_guild
public
bool
$manage_guild
$manage_messages
public
bool
$manage_messages
$manage_nicknames
public
bool
$manage_nicknames
$manage_roles
public
bool
$manage_roles
$manage_threads
public
bool
$manage_threads
$manage_webhooks
public
bool
$manage_webhooks
$mention_everyone
public
bool
$mention_everyone
$moderate_members
public
bool
$moderate_members
$move_members
public
bool
$move_members
$mute_members
public
bool
$mute_members
$priority_speaker
public
bool
$priority_speaker
$read_message_history
public
bool
$read_message_history
$request_to_speak
public
bool
$request_to_speak
$scriptData
Custom script data.
public
mixed
$scriptData
Used for storing custom information, used by end products.
Tags
$send_messages
public
bool
$send_messages
$send_messages_in_threads
public
bool
$send_messages_in_threads
$send_tts_messages
public
bool
$send_tts_messages
$speak
public
bool
$speak
$stream
public
bool
$stream
$use_application_commands
public
bool
$use_application_commands
$use_embedded_activities
public
bool
$use_embedded_activities
$use_external_emojis
public
bool
$use_external_emojis
$use_external_stickers
public
bool
$use_external_stickers
$use_vad
public
bool
$use_vad
$view_audit_log
public
bool
$view_audit_log
$view_channel
public
bool
$view_channel
$view_creator_monetization_analytics
public
bool
$view_creator_monetization_analytics
$view_guild_insights
public
bool
$view_guild_insights
$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
= []
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
= []
$permissions
Array of permissions.
private
array<string|int, mixed>
$permissions
= []
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()
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>
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 —getCreatableAttributes()
Returns the attributes needed to create.
public
getCreatableAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —getPermissions()
Returns an array of extra permissions.
public
static getPermissions() : array<string|int, mixed>
Return values
array<string|int, mixed> —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>
Note: The order matters for repository tree (top to bottom).
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 —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 —getBitwiseAttribute()
Gets the bitwise attribute of the permission.
protected
getBitwiseAttribute() : int|string
Tags
Return values
int|string —setBitwiseAttribute()
Sets the bitwise attribute of the permission.
protected
setBitwiseAttribute(int|string $bitwise) : mixed
Parameters
- $bitwise : int|string
Tags
Return values
mixed —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.