D++ (DPP)
C++ Discord API Bot Library
|
Represents a role within a dpp::guild. Roles are combined via logical OR of the permission bitmasks, then channel-specific overrides can be applied on top, deny types apply a logic NOT to the bit mask, and allows apply a logical OR. More...
#include <role.h>
Public Member Functions | |
role () | |
Construct a new role object. More... | |
virtual | ~role () |
Destroy the role object. More... | |
role & | set_name (const std::string &n) |
Set the name of the role Maximum length: 100 Minimum length: 1. More... | |
role & | set_colour (uint32_t c) |
Set the colour. More... | |
role & | set_color (uint32_t c) |
Set the color. More... | |
role & | set_flags (uint8_t f) |
Set the flags. More... | |
role & | set_integration_id (snowflake i) |
Set the integration id. More... | |
role & | set_bot_id (snowflake b) |
Set the bot id. More... | |
role & | set_guild_id (snowflake gid) |
Set the guild id. More... | |
role & | fill_from_json (nlohmann::json *j) |
Fill this role from json. More... | |
role & | fill_from_json (snowflake guild_id, nlohmann::json *j) |
Fill this role from json. More... | |
virtual std::string | build_json (bool with_id=false) const |
Build a json string from this object. More... | |
std::string | get_mention () const |
Get the mention/ping for the role. More... | |
std::string | get_icon_url (uint16_t size=0, const image_type format=i_png) const |
Returns the role's icon url if they have one, otherwise returns an empty string. More... | |
role & | load_image (const std::string &image_blob, const image_type type) |
Load an image into the object as base64. More... | |
bool | operator== (const role &other) const |
Operator equals, used for checking if a role is ranked equal to another. More... | |
bool | operator!= (const role &other) const |
Operator not equals, used for checking if a role is ranked equal to another. More... | |
bool | is_hoisted () const |
True if the role is hoisted. More... | |
bool | is_mentionable () const |
True if the role is mentionable. More... | |
bool | is_managed () const |
True if the role is managed (belongs to a bot or application) More... | |
bool | has_create_instant_invite () const |
True if has create instant invite permission. More... | |
bool | has_kick_members () const |
True if has the kick members permission. More... | |
bool | has_ban_members () const |
True if has the ban members permission. More... | |
bool | has_administrator () const |
True if has the administrator permission. More... | |
bool | has_manage_channels () const |
True if has the manage channels permission. More... | |
bool | has_manage_guild () const |
True if has the manage guild permission. More... | |
bool | has_add_reactions () const |
True if has the add reactions permission. More... | |
bool | has_view_audit_log () const |
True if has the view audit log permission. More... | |
bool | has_priority_speaker () const |
True if has the priority speaker permission. More... | |
bool | has_stream () const |
True if has the stream permission. More... | |
bool | has_view_channel () const |
True if has the view channel permission. More... | |
bool | has_send_messages () const |
True if has the send messages permission. More... | |
bool | has_send_tts_messages () const |
True if has the send TTS messages permission. More... | |
bool | has_manage_messages () const |
True if has the manage messages permission. More... | |
bool | has_embed_links () const |
True if has the embed links permission. More... | |
bool | has_attach_files () const |
True if has the attach files permission. More... | |
bool | has_read_message_history () const |
True if has the read message history permission. More... | |
bool | has_mention_everyone () const |
True if has the mention @everyone and @here permission. More... | |
bool | has_use_external_emojis () const |
True if has the use external emojis permission. More... | |
bool | has_view_guild_insights () const |
True if has the view guild insights permission. More... | |
bool | has_connect () const |
True if has the connect voice permission. More... | |
bool | has_speak () const |
True if has the speak permission. More... | |
bool | has_mute_members () const |
True if has the mute members permission. More... | |
bool | has_deafen_members () const |
True if has the deafen members permission. More... | |
bool | has_move_members () const |
True if has the move members permission. More... | |
bool | has_use_vad () const |
bool | has_change_nickname () const |
True if has the change nickname permission. More... | |
bool | has_manage_nicknames () const |
True if has the manage nicknames permission. More... | |
bool | has_manage_roles () const |
True if has the manage roles permission. More... | |
bool | has_manage_webhooks () const |
True if has the manage webhooks permission. More... | |
bool | has_manage_emojis_and_stickers () const |
True if has the manage emojis and stickers permission. More... | |
bool | has_use_application_commands () const |
True if has the use application commands permission. More... | |
bool | has_request_to_speak () const |
True if has the request to speak permission. More... | |
bool | has_manage_threads () const |
True if has the manage threads permission. More... | |
bool | has_create_public_threads () const |
True if has the create public threads permission. More... | |
bool | has_create_private_threads () const |
True if has the create private threads permission. More... | |
bool | has_use_external_stickers () const |
True if has the use external stickers permission. More... | |
bool | has_send_messages_in_threads () const |
True if has the send messages in threads permission. More... | |
bool | has_use_embedded_activities () const |
True if has the start embedded activities permission. More... | |
bool | has_manage_events () const |
True if has the manage events permission. More... | |
bool | has_moderate_members () const |
True if has the moderate users permission. More... | |
members_container | get_members () const |
Get guild members who have this role. More... | |
double | get_creation_time () const |
Get the creation time of this object according to Discord. More... | |
bool | operator== (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
bool | operator!= (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
Static Public Member Functions | |
static std::string | get_mention (const snowflake &id) |
Create a mentionable role. More... | |
Public Attributes | |
std::string | name |
Role name Between 1 and 100 characters. More... | |
snowflake | guild_id |
Guild ID. More... | |
uint32_t | colour |
Role colour. A colour of 0 means no colour. If you want a black role, you must use the value 0x000001. More... | |
uint8_t | position |
permission | permissions |
uint8_t | flags |
snowflake | integration_id |
snowflake | bot_id |
std::string | unicode_emoji |
utility::iconhash | icon |
std::string * | image_data |
snowflake | id |
Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata. More... | |
Friends | |
bool | operator< (const role &lhs, const role &rhs) |
Operator less than, used for checking if a role is below another. More... | |
bool | operator> (const role &lhs, const role &rhs) |
Operator greater than, used for checking if a role is above another. More... | |
Represents a role within a dpp::guild. Roles are combined via logical OR of the permission bitmasks, then channel-specific overrides can be applied on top, deny types apply a logic NOT to the bit mask, and allows apply a logical OR.
dpp::role::role | ( | ) |
Construct a new role object.
|
virtual |
Destroy the role object.
|
virtual |
Build a json string from this object.
with_id | true if the ID is to be included in the json text |
Reimplemented from dpp::json_interface< role >.
role & dpp::role::fill_from_json | ( | nlohmann::json * | j | ) |
Fill this role from json.
j | The json data |
Fill this role from json.
guild_id | the guild id to place in the json |
j | The json data |
|
inherited |
Get the creation time of this object according to Discord.
std::string dpp::role::get_icon_url | ( | uint16_t | size = 0 , |
const image_type | format = i_png |
||
) | const |
Returns the role's icon url if they have one, otherwise returns an empty string.
size | The size of the icon in pixels. It can be any power of two between 16 and 4096, otherwise the default sized icon is returned. |
format | The format to use for the avatar. It can be one of i_webp , i_jpg or i_png . |
members_container dpp::role::get_members | ( | ) | const |
Get guild members who have this role.
std::string dpp::role::get_mention | ( | ) | const |
Get the mention/ping for the role.
|
static |
Create a mentionable role.
id | The ID of the role. |
bool dpp::role::has_add_reactions | ( | ) | const |
True if has the add reactions permission.
bool dpp::role::has_administrator | ( | ) | const |
True if has the administrator permission.
bool dpp::role::has_attach_files | ( | ) | const |
True if has the attach files permission.
bool dpp::role::has_ban_members | ( | ) | const |
True if has the ban members permission.
bool dpp::role::has_change_nickname | ( | ) | const |
True if has the change nickname permission.
bool dpp::role::has_connect | ( | ) | const |
True if has the connect voice permission.
bool dpp::role::has_create_instant_invite | ( | ) | const |
True if has create instant invite permission.
bool dpp::role::has_create_private_threads | ( | ) | const |
True if has the create private threads permission.
bool dpp::role::has_create_public_threads | ( | ) | const |
True if has the create public threads permission.
bool dpp::role::has_deafen_members | ( | ) | const |
True if has the deafen members permission.
bool dpp::role::has_embed_links | ( | ) | const |
True if has the embed links permission.
bool dpp::role::has_kick_members | ( | ) | const |
True if has the kick members permission.
bool dpp::role::has_manage_channels | ( | ) | const |
True if has the manage channels permission.
bool dpp::role::has_manage_emojis_and_stickers | ( | ) | const |
True if has the manage emojis and stickers permission.
bool dpp::role::has_manage_events | ( | ) | const |
True if has the manage events permission.
bool dpp::role::has_manage_guild | ( | ) | const |
True if has the manage guild permission.
bool dpp::role::has_manage_messages | ( | ) | const |
True if has the manage messages permission.
bool dpp::role::has_manage_nicknames | ( | ) | const |
True if has the manage nicknames permission.
bool dpp::role::has_manage_roles | ( | ) | const |
True if has the manage roles permission.
bool dpp::role::has_manage_threads | ( | ) | const |
True if has the manage threads permission.
bool dpp::role::has_manage_webhooks | ( | ) | const |
True if has the manage webhooks permission.
bool dpp::role::has_mention_everyone | ( | ) | const |
True if has the mention @everyone and @here permission.
bool dpp::role::has_moderate_members | ( | ) | const |
True if has the moderate users permission.
bool dpp::role::has_move_members | ( | ) | const |
True if has the move members permission.
bool dpp::role::has_mute_members | ( | ) | const |
True if has the mute members permission.
bool dpp::role::has_priority_speaker | ( | ) | const |
True if has the priority speaker permission.
bool dpp::role::has_read_message_history | ( | ) | const |
True if has the read message history permission.
bool dpp::role::has_request_to_speak | ( | ) | const |
True if has the request to speak permission.
bool dpp::role::has_send_messages | ( | ) | const |
True if has the send messages permission.
bool dpp::role::has_send_messages_in_threads | ( | ) | const |
True if has the send messages in threads permission.
bool dpp::role::has_send_tts_messages | ( | ) | const |
True if has the send TTS messages permission.
bool dpp::role::has_speak | ( | ) | const |
True if has the speak permission.
bool dpp::role::has_stream | ( | ) | const |
True if has the stream permission.
bool dpp::role::has_use_application_commands | ( | ) | const |
True if has the use application commands permission.
bool dpp::role::has_use_embedded_activities | ( | ) | const |
True if has the start embedded activities permission.
bool dpp::role::has_use_external_emojis | ( | ) | const |
True if has the use external emojis permission.
bool dpp::role::has_use_external_stickers | ( | ) | const |
True if has the use external stickers permission.
bool dpp::role::has_use_vad | ( | ) | const |
True if has use voice activity detection permission
bool dpp::role::has_view_audit_log | ( | ) | const |
True if has the view audit log permission.
bool dpp::role::has_view_channel | ( | ) | const |
True if has the view channel permission.
bool dpp::role::has_view_guild_insights | ( | ) | const |
True if has the view guild insights permission.
bool dpp::role::is_hoisted | ( | ) | const |
True if the role is hoisted.
bool dpp::role::is_managed | ( | ) | const |
True if the role is managed (belongs to a bot or application)
bool dpp::role::is_mentionable | ( | ) | const |
True if the role is mentionable.
role & dpp::role::load_image | ( | const std::string & | image_blob, |
const image_type | type | ||
) |
Load an image into the object as base64.
image_blob | Image binary data |
type | Type of image. It can be one of i_gif , i_jpg or i_png . |
|
noexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
|
inline |
Operator not equals, used for checking if a role is ranked equal to another.
other | role to compare |
|
noexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
|
inline |
Operator equals, used for checking if a role is ranked equal to another.
other | role to compare |
Set the bot id.
b | Bot ID to set |
role & dpp::role::set_color | ( | uint32_t | c | ) |
Set the color.
c | Colour to set |
role & dpp::role::set_colour | ( | uint32_t | c | ) |
Set the colour.
c | Colour to set |
role & dpp::role::set_flags | ( | uint8_t | f | ) |
Set the guild id.
gid | Guild ID to set |
Set the integration id.
i | Integration ID to set |
role & dpp::role::set_name | ( | const std::string & | n | ) |
Set the name of the role Maximum length: 100 Minimum length: 1.
n | Name to set |
dpp::exception | thrown if role length is less than 1 character |
Operator less than, used for checking if a role is below another.
lhs | first role to compare |
rhs | second role to compare |
Operator greater than, used for checking if a role is above another.
lhs | first role to compare |
rhs | second role to compare |
snowflake dpp::role::bot_id |
Bot id if any (e.g. role is a bot's role created when it was invited)
uint32_t dpp::role::colour |
Role colour. A colour of 0 means no colour. If you want a black role, you must use the value 0x000001.
uint8_t dpp::role::flags |
Role flags from dpp::role_flags
snowflake dpp::role::guild_id |
Guild ID.
utility::iconhash dpp::role::icon |
The role icon hash, can be an empty string
|
inherited |
Unique ID of object set by Discord. This value contains a timestamp, worker ID, internal server ID, and an incrementing value. Only the timestamp is relevant to us as useful metadata.
std::string* dpp::role::image_data |
Image data for the role icon (if any)
snowflake dpp::role::integration_id |
Integration id if any (e.g. role is a bot's role created when it was invited)
std::string dpp::role::name |
Role name Between 1 and 100 characters.
permission dpp::role::permissions |
Role permissions bitmask values from dpp::permissions
uint8_t dpp::role::position |
Role position
std::string dpp::role::unicode_emoji |
The unicode emoji used for the role's icon, can be an empty string