Represents a role within a dpp::guild. More...
#include "role.h"
Public Member Functions | |
role ()=default | |
Construct a new role object. More... | |
role (const role &rhs)=default | |
Construct a new role object. More... | |
role (role &&rhs)=default | |
Construct a new role object. More... | |
virtual | ~role ()=default |
Destroy the role object. More... | |
std::string | build_json (bool with_id=false) const |
Convert object to json string. More... | |
role & | fill_from_json (nlohmann::json *j) |
Convert object from nlohmann::json. More... | |
role & | fill_from_json (snowflake guild_id, nlohmann::json *j) |
Fill this role from json. More... | |
constexpr double | get_creation_time () const noexcept |
Get the creation time of this object according to Discord. 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... | |
members_container | get_members () const |
Get guild members who have this role. More... | |
std::string | get_mention () const |
Get the mention/ping for the role. More... | |
bool | has_add_reactions () const |
True if has the add reactions permission. More... | |
bool | has_administrator () const |
True if has the administrator permission. More... | |
bool | has_attach_files () const |
True if has the attach files permission. More... | |
bool | has_ban_members () const |
True if has the ban members permission. More... | |
bool | has_change_nickname () const |
True if has the change nickname permission. More... | |
bool | has_connect () const |
True if has the connect voice permission. More... | |
bool | has_create_instant_invite () const |
True if has create instant invite permission. More... | |
bool | has_create_private_threads () const |
True if has the create private threads permission. More... | |
bool | has_create_public_threads () const |
True if has the create public threads permission. More... | |
bool | has_deafen_members () const |
True if has the deafen members permission. More... | |
bool | has_embed_links () const |
True if has the embed links permission. More... | |
bool | has_kick_members () const |
True if has the kick members permission. More... | |
bool | has_manage_channels () const |
True if has the manage channels permission. More... | |
bool | has_manage_emojis_and_stickers () const |
True if has the manage emojis and stickers permission. More... | |
bool | has_manage_events () const |
True if has the manage events permission. More... | |
bool | has_manage_guild () const |
True if has the manage guild permission. More... | |
bool | has_manage_messages () const |
True if has the manage messages 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_threads () const |
True if has the manage threads permission. More... | |
bool | has_manage_webhooks () const |
True if has the manage webhooks permission. More... | |
bool | has_mention_everyone () const |
True if has the mention @everyone and @here permission. More... | |
bool | has_moderate_members () const |
True if has the moderate users permission. More... | |
bool | has_move_members () const |
True if has the move members permission. More... | |
bool | has_mute_members () const |
True if has the mute members permission. More... | |
bool | has_priority_speaker () const |
True if has the priority speaker permission. More... | |
bool | has_read_message_history () const |
True if has the read message history permission. More... | |
bool | has_request_to_speak () const |
True if has the request to speak permission. More... | |
bool | has_send_messages () const |
True if has the send messages permission. More... | |
bool | has_send_messages_in_threads () const |
True if has the send messages in threads permission. More... | |
bool | has_send_tts_messages () const |
True if has the send TTS messages permission. More... | |
bool | has_send_voice_messages () const |
True if has the send voice messages permission. More... | |
bool | has_speak () const |
True if has the speak permission. More... | |
bool | has_stream () const |
True if has the stream permission. More... | |
bool | has_use_application_commands () const |
True if has the use application commands permission. More... | |
bool | has_use_clyde_ai () const |
True if has permission to use clyde AI. More... | |
bool | has_use_embedded_activities () const |
True if has the start embedded activities permission. More... | |
bool | has_use_external_emojis () const |
True if has the use external emojis permission. More... | |
bool | has_use_external_sounds () const |
True if has the use external sounds permission. More... | |
bool | has_use_external_stickers () const |
True if has the use external stickers permission. More... | |
bool | has_use_soundboard () const |
True if has the use soundboard permission. More... | |
bool | has_use_vad () const |
True if has use voice activity detection permission. More... | |
bool | has_view_audit_log () const |
True if has the view audit log permission. More... | |
bool | has_view_channel () const |
True if has the view channel permission. More... | |
bool | has_view_creator_monetization_analytics () const |
True if has the view creator monetization analytics permission. More... | |
bool | has_view_guild_insights () const |
True if has the view guild insights permission. More... | |
bool | is_available_for_purchase () const |
True if the role is available for purchase. More... | |
bool | is_hoisted () const |
True if the role is hoisted. More... | |
bool | is_linked () const |
True if the role is a linked role. More... | |
bool | is_managed () const |
True if the role is managed (belongs to a bot or application). More... | |
bool | is_mentionable () const |
True if the role is mentionable. More... | |
bool | is_premium_subscriber () const |
True if the role is the guild's Booster role. More... | |
bool | is_selectable_in_prompt () const |
True if the role can be selected by members in an onboarding prompt. More... | |
role & | load_image (const std::byte *data, uint32_t size, const image_type type) |
Load a role icon. More... | |
role & | load_image (std::string_view image_blob, const image_type type) |
Load a role icon. More... | |
constexpr bool | operator!= (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
bool | operator!= (const role &other) const |
Operator not equals, used for checking if a role is ranked equal to another. More... | |
role & | operator= (const role &rhs)=default |
Copy another role object. More... | |
role & | operator= (role &&rhs)=default |
Move from another role object. More... | |
constexpr bool | operator== (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
bool | operator== (const role &other) const |
Operator equals, used for checking if a role is ranked equal to another. More... | |
role & | set_bot_id (snowflake b) |
Set the bot ID. More... | |
role & | set_color (uint32_t c) |
Set the color. More... | |
role & | set_colour (uint32_t c) |
Set the colour. More... | |
role & | set_flags (uint8_t f) |
Set the flags. More... | |
role & | set_guild_id (snowflake gid) |
Set the guild ID. More... | |
role & | set_integration_id (snowflake i) |
Set the integration ID. More... | |
role & | set_name (const std::string &n) |
Set the name of the role. More... | |
auto | to_json (bool with_id=false) const |
Convert object to nlohmann::json. More... | |
Static Public Member Functions | |
static std::string | get_mention (const snowflake &id) |
Create a mentionable role. More... | |
Public Attributes | |
snowflake | bot_id {} |
Bot id if any. More... | |
uint32_t | colour {0} |
Role colour. More... | |
uint8_t | flags {0} |
Role flags from dpp::role_flags. More... | |
snowflake | guild_id {0} |
Guild ID. More... | |
utility::icon | icon {} |
The role icon. More... | |
snowflake | id = {} |
Unique ID of object set by Discord. More... | |
snowflake | integration_id {} |
Integration id if any. More... | |
std::string | name {} |
Role name Between 1 and 100 characters. More... | |
permission | permissions {} |
Role permissions bitmask values from dpp::permissions. More... | |
uint8_t | position {0} |
Role position. More... | |
snowflake | subscription_listing_id {} |
The id of the role's subscription sku and listing. More... | |
std::string | unicode_emoji {} |
The unicode emoji used for the role's icon. More... | |
Protected Member Functions | |
role & | fill_from_json_impl (nlohmann::json *j) |
Fill this role from json. More... | |
virtual json | to_json_impl (bool with_id=false) const |
Build a json from this object. More... | |
Friends | |
struct | json_interface< role > |
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.
|
default |
Construct a new role object.
|
default |
Construct a new role object.
rhs | Role object to copy |
|
default |
Construct a new role object.
rhs | Role object to move |
|
virtualdefault |
Destroy the role object.
|
inlineinherited |
Convert object to json string.
with_id | Whether to include the ID or not |
|
inlineinherited |
Convert object from nlohmann::json.
j | nlohmann::json object |
role & dpp::role::fill_from_json | ( | snowflake | guild_id, |
nlohmann::json * | j | ||
) |
Fill this role from json.
guild_id | the guild id to place in the json |
j | The json data |
References bot_id, flags, integration_id, dpp::r_available_for_purchase, dpp::r_guild_connections, dpp::r_premium_subscriber, dpp::snowflake_not_null(), and subscription_listing_id.
|
protected |
Fill this role from json.
j | The json data |
|
inlineconstexprnoexceptinherited |
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 . |
References dpp::application_role_connection_metadata::name_localizations.
members_container dpp::role::get_members | ( | ) | const |
Get guild members who have this role.
References dpp::utility::icon::as_iconhash(), dpp::utility::cdn_endpoint_url(), dpp::i_jpg, dpp::i_png, dpp::i_webp, icon, dpp::utility::icon::is_iconhash(), and dpp::utility::iconhash::to_string().
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.
References has_administrator(), and dpp::p_send_messages.
bool dpp::role::has_administrator | ( | ) | const |
True if has the administrator permission.
References dpp::p_priority_speaker.
Referenced by has_add_reactions(), has_attach_files(), has_ban_members(), has_change_nickname(), has_connect(), has_create_instant_invite(), has_create_private_threads(), has_create_public_threads(), has_deafen_members(), has_embed_links(), has_kick_members(), has_manage_channels(), has_manage_emojis_and_stickers(), has_manage_events(), has_manage_guild(), has_manage_messages(), has_manage_nicknames(), has_manage_roles(), has_manage_threads(), has_manage_webhooks(), has_mention_everyone(), has_moderate_members(), has_move_members(), has_mute_members(), has_priority_speaker(), has_read_message_history(), has_request_to_speak(), has_send_messages(), has_send_messages_in_threads(), has_send_tts_messages(), has_speak(), has_stream(), has_use_application_commands(), has_use_embedded_activities(), has_use_external_emojis(), has_use_external_stickers(), has_use_vad(), has_view_audit_log(), has_view_channel(), has_view_guild_insights(), is_available_for_purchase(), is_managed(), is_premium_subscriber(), and is_selectable_in_prompt().
bool dpp::role::has_attach_files | ( | ) | const |
True if has the attach files permission.
References has_administrator(), and dpp::p_connect.
bool dpp::role::has_ban_members | ( | ) | const |
True if has the ban members permission.
References has_administrator(), and dpp::p_view_audit_log.
bool dpp::role::has_change_nickname | ( | ) | const |
True if has the change nickname permission.
References has_administrator(), and dpp::p_use_application_commands.
bool dpp::role::has_connect | ( | ) | const |
True if has the connect voice permission.
References has_administrator(), and dpp::p_use_vad.
bool dpp::role::has_create_instant_invite | ( | ) | const |
True if has create instant invite permission.
References has_administrator(), and dpp::p_manage_guild.
bool dpp::role::has_create_private_threads | ( | ) | const |
True if has the create private threads permission.
References has_administrator(), and dpp::p_moderate_members.
bool dpp::role::has_create_public_threads | ( | ) | const |
True if has the create public threads permission.
References has_administrator(), and dpp::p_manage_events.
bool dpp::role::has_deafen_members | ( | ) | const |
True if has the deafen members permission.
References has_administrator(), and dpp::p_manage_roles.
bool dpp::role::has_embed_links | ( | ) | const |
True if has the embed links permission.
References has_administrator(), and dpp::p_view_guild_insights.
bool dpp::role::has_kick_members | ( | ) | const |
True if has the kick members permission.
References has_administrator(), and dpp::p_add_reactions.
bool dpp::role::has_manage_channels | ( | ) | const |
True if has the manage channels permission.
References has_administrator(), and dpp::p_stream.
bool dpp::role::has_manage_emojis_and_stickers | ( | ) | const |
True if has the manage emojis and stickers permission.
References has_administrator(), and dpp::p_create_private_threads.
bool dpp::role::has_manage_events | ( | ) | const |
True if has the manage events permission.
References has_administrator(), and dpp::p_send_voice_messages.
bool dpp::role::has_manage_guild | ( | ) | const |
True if has the manage guild permission.
References has_administrator(), and dpp::p_view_channel.
bool dpp::role::has_manage_messages | ( | ) | const |
True if has the manage messages permission.
References has_administrator(), and dpp::p_use_external_emojis.
bool dpp::role::has_manage_nicknames | ( | ) | const |
True if has the manage nicknames permission.
References has_administrator(), and dpp::p_request_to_speak.
bool dpp::role::has_manage_roles | ( | ) | const |
True if has the manage roles permission.
References has_administrator(), and dpp::p_manage_threads.
bool dpp::role::has_manage_threads | ( | ) | const |
True if has the manage threads permission.
References has_administrator(), and dpp::p_use_embedded_activities.
bool dpp::role::has_manage_webhooks | ( | ) | const |
True if has the manage webhooks permission.
References has_administrator(), and dpp::p_create_public_threads.
bool dpp::role::has_mention_everyone | ( | ) | const |
True if has the mention @everyone and @here permission.
References has_administrator(), and dpp::p_mute_members.
bool dpp::role::has_moderate_members | ( | ) | const |
True if has the moderate users permission.
References has_administrator(), and dpp::p_use_clyde_ai.
bool dpp::role::has_move_members | ( | ) | const |
True if has the move members permission.
References has_administrator(), and dpp::p_manage_webhooks.
bool dpp::role::has_mute_members | ( | ) | const |
True if has the mute members permission.
References has_administrator(), and dpp::p_manage_nicknames.
bool dpp::role::has_priority_speaker | ( | ) | const |
True if has the priority speaker permission.
References has_administrator(), and dpp::p_manage_messages.
bool dpp::role::has_read_message_history | ( | ) | const |
True if has the read message history permission.
References has_administrator(), and dpp::p_speak.
bool dpp::role::has_request_to_speak | ( | ) | const |
True if has the request to speak permission.
References has_administrator(), and dpp::p_send_messages_in_threads.
bool dpp::role::has_send_messages | ( | ) | const |
True if has the send messages permission.
References has_administrator(), and dpp::p_read_message_history.
bool dpp::role::has_send_messages_in_threads | ( | ) | const |
True if has the send messages in threads permission.
References has_administrator(), and dpp::p_use_soundboard.
bool dpp::role::has_send_tts_messages | ( | ) | const |
True if has the send TTS messages permission.
References has_administrator(), and dpp::p_mention_everyone.
bool dpp::role::has_send_voice_messages | ( | ) | const |
True if has the send voice messages permission.
bool dpp::role::has_speak | ( | ) | const |
True if has the speak permission.
References has_administrator(), and dpp::p_change_nickname.
bool dpp::role::has_stream | ( | ) | const |
True if has the stream permission.
References has_administrator(), and dpp::p_embed_links.
bool dpp::role::has_use_application_commands | ( | ) | const |
True if has the use application commands permission.
References has_administrator(), and dpp::p_use_external_stickers.
bool dpp::role::has_use_clyde_ai | ( | ) | const |
True if has permission to use clyde AI.
bool dpp::role::has_use_embedded_activities | ( | ) | const |
True if has the start embedded activities permission.
References has_administrator(), and dpp::p_use_external_sounds.
bool dpp::role::has_use_external_emojis | ( | ) | const |
True if has the use external emojis permission.
References has_administrator(), and dpp::p_deafen_members.
bool dpp::role::has_use_external_sounds | ( | ) | const |
True if has the use external sounds permission.
bool dpp::role::has_use_external_stickers | ( | ) | const |
True if has the use external stickers permission.
References has_administrator(), and dpp::p_view_creator_monetization_analytics.
bool dpp::role::has_use_soundboard | ( | ) | const |
True if has the use soundboard permission.
References colour.
bool dpp::role::has_use_vad | ( | ) | const |
True if has use voice activity detection permission.
References has_administrator(), and dpp::p_manage_emojis_and_stickers.
bool dpp::role::has_view_audit_log | ( | ) | const |
True if has the view audit log permission.
References has_administrator(), and dpp::p_send_tts_messages.
bool dpp::role::has_view_channel | ( | ) | const |
True if has the view channel permission.
References has_administrator(), and dpp::p_attach_files.
bool dpp::role::has_view_creator_monetization_analytics | ( | ) | const |
True if has the view creator monetization analytics permission.
References name, and dpp::utility::validate().
bool dpp::role::has_view_guild_insights | ( | ) | const |
True if has the view guild insights permission.
References has_administrator(), and dpp::p_move_members.
bool dpp::role::is_available_for_purchase | ( | ) | const |
True if the role is available for purchase.
References has_administrator(), and dpp::p_ban_members.
bool dpp::role::is_hoisted | ( | ) | const |
True if the role is hoisted.
References flags, and dpp::r_guild_connections.
bool dpp::role::is_linked | ( | ) | const |
True if the role is a linked role.
References dpp::p_administrator.
bool dpp::role::is_managed | ( | ) | const |
True if the role is managed (belongs to a bot or application).
References has_administrator(), and dpp::p_create_instant_invite.
bool dpp::role::is_mentionable | ( | ) | const |
True if the role is mentionable.
References flags, and dpp::r_in_prompt.
bool dpp::role::is_premium_subscriber | ( | ) | const |
True if the role is the guild's Booster role.
References has_administrator(), and dpp::p_kick_members.
bool dpp::role::is_selectable_in_prompt | ( | ) | const |
True if the role can be selected by members in an onboarding prompt.
References has_administrator(), and dpp::p_manage_channels.
role & dpp::role::load_image | ( | const std::byte * | data, |
uint32_t | size, | ||
const image_type | type | ||
) |
Load a role icon.
data | Image binary data |
size | Size of the image. |
type | Type of image. It can be one of i_gif , i_jpg or i_png . |
role & dpp::role::load_image | ( | std::string_view | image_blob, |
const image_type | type | ||
) |
Load a role icon.
image_blob | Image binary data |
type | Type of image. It can be one of i_gif , i_jpg or i_png . |
|
inlineconstexprnoexceptinherited |
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 |
Copy another role object.
rhs | Role object to copy |
Move from another role object.
rhs | Role object to copy |
|
inlineconstexprnoexceptinherited |
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 flags.
f | Flags to set from dpp::role_flags |
References dpp::find_guild(), and guild_id.
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 |
|
inlineinherited |
Convert object to nlohmann::json.
with_id | Whether to include the ID or not |
|
protectedvirtual |
Build a json from this object.
with_id | true if the ID is to be included in the json |
|
friend |
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)
Referenced by fill_from_json().
uint32_t dpp::role::colour {0} |
Role colour.
A colour of 0 means no colour. If you want a black role, you must use the value 0x000001.
Referenced by has_use_soundboard().
uint8_t dpp::role::flags {0} |
Role flags from dpp::role_flags.
Referenced by fill_from_json(), is_hoisted(), and is_mentionable().
snowflake dpp::role::guild_id {0} |
Guild ID.
Referenced by set_flags().
utility::icon dpp::role::icon {} |
The role icon.
Referenced by get_members().
|
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.
Referenced by dpp::poll::add_answer(), dpp::cluster::create_webhook(), dpp::cluster::current_user_join_thread(), dpp::invite::fill_from_json_impl(), dpp::command_permission::fill_from_json_impl(), dpp::interaction::get_resolved_role(), dpp::interaction::get_resolved_user(), dpp::cluster::global_bulk_command_create(), dpp::cluster::global_bulk_command_delete(), dpp::cluster::global_command_delete(), dpp::cluster::global_command_edit(), dpp::cluster::guild_ban_delete(), dpp::cluster::guild_command_create(), dpp::cluster::guild_command_edit_permissions(), dpp::cluster::guild_get_integrations(), dpp::events::guild_member_update::handle(), dpp::events::guild_role_create::handle(), dpp::events::channel_create::handle(), dpp::events::voice_state_update::handle(), dpp::discord_voice_client::handle_frame(), main(), dpp::component::set_disabled(), and dpp::select_option::set_label().
snowflake dpp::role::integration_id {} |
Integration id if any.
(e.g. role is a bot's role created when it was invited).
Referenced by fill_from_json().
std::string dpp::role::name {} |
Role name Between 1 and 100 characters.
Referenced by has_view_creator_monetization_analytics().
permission dpp::role::permissions {} |
Role permissions bitmask values from dpp::permissions.
Referenced by dpp::guild_widget::to_json_impl().
uint8_t dpp::role::position {0} |
Role position.
snowflake dpp::role::subscription_listing_id {} |
The id of the role's subscription sku and listing.
Referenced by fill_from_json().
std::string dpp::role::unicode_emoji {} |
The unicode emoji used for the role's icon.