D++ (DPP)
C++ Discord API Bot Library
dpp::role Class Reference

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...

+ Inheritance diagram for dpp::role:
+ Collaboration diagram for dpp::role:

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...
 
roleoperator= (const role &rhs)=default
 Copy another role object. More...
 
roleoperator= (role &&rhs)=default
 Move from another role object. More...
 
virtual ~role ()=default
 Destroy the role object. More...
 
roleset_name (const std::string &n)
 Set the name of the role. Maximum length: 100 Minimum length: 1. More...
 
roleset_colour (uint32_t c)
 Set the colour. More...
 
roleset_color (uint32_t c)
 Set the color. More...
 
roleset_flags (uint8_t f)
 Set the flags. More...
 
roleset_integration_id (snowflake i)
 Set the integration ID. More...
 
roleset_bot_id (snowflake b)
 Set the bot ID. More...
 
roleset_guild_id (snowflake gid)
 Set the guild ID. More...
 
rolefill_from_json (snowflake guild_id, nlohmann::json *j)
 Fill this role from json. 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...
 
roleload_image (std::string_view image_blob, const image_type type)
 Load a role icon. More...
 
roleload_image (const std::byte *data, uint32_t size, const image_type type)
 Load a role icon. 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 is_premium_subscriber () const
 True if the role is the guild's Booster role. More...
 
bool is_available_for_purchase () const
 True if the role is available for purchase. More...
 
bool is_linked () const
 True if the role is a linked role. More...
 
bool is_selectable_in_prompt () const
 True if the role can be selected by members in an onboarding prompt. 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
 True if has use voice activity detection permission. More...
 
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...
 
bool has_view_creator_monetization_analytics () const
 True if has the view creator monetization analytics permission. More...
 
bool has_use_soundboard () const
 True if has the use soundboard permission. More...
 
bool has_use_external_sounds () const
 True if has the use external sounds permission. More...
 
bool has_send_voice_messages () const
 True if has the send voice messages permission. More...
 
bool has_use_clyde_ai () const
 True if has permission to use clyde AI. More...
 
members_container get_members () const
 Get guild members who have this role. More...
 
constexpr double get_creation_time () const noexcept
 Get the creation time of this object according to Discord. More...
 
constexpr bool operator== (const managed &other) const noexcept
 Comparison operator for comparing two managed objects by id. More...
 
constexpr bool operator!= (const managed &other) const noexcept
 Comparison operator for comparing two managed objects by id. More...
 
rolefill_from_json (nlohmann::json *j)
 Convert object from nlohmann::json. More...
 
auto to_json (bool with_id=false) const
 Convert object to nlohmann::json. More...
 
std::string build_json (bool with_id=false) const
 Convert object to json string. 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 {0}
 Guild ID. More...
 
uint32_t colour {0}
 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 {0}
 Role position. More...
 
permission permissions {}
 Role permissions bitmask values from dpp::permissions. More...
 
uint8_t flags {0}
 Role flags from dpp::role_flags. More...
 
snowflake integration_id {}
 Integration id if any. (e.g. role is a bot's role created when it was invited). More...
 
snowflake bot_id {}
 Bot id if any. (e.g. role is a bot's role created when it was invited) 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...
 
utility::icon icon {}
 The role icon. More...
 
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...
 

Protected Member Functions

rolefill_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...
 

Detailed Description

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.

Note
Every guild has at least one role, called the 'everyone' role, which always has the same role ID as the guild's ID. This is the base permission set applied to all users where no other role or override applies, and is the starting value of the bit mask looped through to calculate channel permissions.

Constructor & Destructor Documentation

◆ role() [1/3]

dpp::role::role ( )
default

Construct a new role object.

◆ role() [2/3]

dpp::role::role ( const role rhs)
default

Construct a new role object.

Parameters
rhsRole object to copy

◆ role() [3/3]

dpp::role::role ( role &&  rhs)
default

Construct a new role object.

Parameters
rhsRole object to move

◆ ~role()

virtual dpp::role::~role ( )
virtualdefault

Destroy the role object.

Member Function Documentation

◆ build_json()

std::string dpp::json_interface< role >::build_json ( bool  with_id = false) const
inlineinherited

Convert object to json string.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
std::string Json built from the structure

◆ fill_from_json() [1/2]

role & dpp::json_interface< role >::fill_from_json ( nlohmann::json *  j)
inlineinherited

Convert object from nlohmann::json.

Parameters
jnlohmann::json object
Returns
T& Reference to self for fluent calling

◆ fill_from_json() [2/2]

role& dpp::role::fill_from_json ( snowflake  guild_id,
nlohmann::json *  j 
)

Fill this role from json.

Parameters
guild_idthe guild id to place in the json
jThe json data
Returns
A reference to self

◆ fill_from_json_impl()

role& dpp::role::fill_from_json_impl ( nlohmann::json *  j)
protected

Fill this role from json.

Parameters
jThe json data
Returns
A reference to self

◆ get_creation_time()

constexpr double dpp::managed::get_creation_time ( ) const
inlineconstexprnoexceptinherited

Get the creation time of this object according to Discord.

Returns
double creation time inferred from the snowflake ID. The minimum possible value is the first second of 2015.

◆ get_icon_url()

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.

Parameters
sizeThe size of the icon in pixels. It can be any power of two between 16 and 4096, otherwise the default sized icon is returned.
formatThe format to use for the avatar. It can be one of i_webp, i_jpg or i_png.
Returns
std::string icon url or an empty string, if required attributes are missing or an invalid format was passed

◆ get_members()

members_container dpp::role::get_members ( ) const

Get guild members who have this role.

Note
This method requires user/members cache to be active
Returns
members_container List of members who have this role

◆ get_mention() [1/2]

std::string dpp::role::get_mention ( ) const

Get the mention/ping for the role.

Returns
std::string mention

◆ get_mention() [2/2]

static std::string dpp::role::get_mention ( const snowflake id)
static

Create a mentionable role.

Parameters
idThe ID of the role.
Returns
std::string The formatted mention of the role.

◆ has_add_reactions()

bool dpp::role::has_add_reactions ( ) const

True if has the add reactions permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the add reactions permission or is administrator.

◆ has_administrator()

bool dpp::role::has_administrator ( ) const

True if has the administrator permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the administrator permission or is administrator.

◆ has_attach_files()

bool dpp::role::has_attach_files ( ) const

True if has the attach files permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the attach files permission or is administrator.

◆ has_ban_members()

bool dpp::role::has_ban_members ( ) const

True if has the ban members permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the ban members permission or is administrator.

◆ has_change_nickname()

bool dpp::role::has_change_nickname ( ) const

True if has the change nickname permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the change nickname permission or is administrator.

◆ has_connect()

bool dpp::role::has_connect ( ) const

True if has the connect voice permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the connect voice permission or is administrator.

◆ has_create_instant_invite()

bool dpp::role::has_create_instant_invite ( ) const

True if has create instant invite permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the instant invite permission or is administrator.

◆ has_create_private_threads()

bool dpp::role::has_create_private_threads ( ) const

True if has the create private threads permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the create private threads permission or is administrator.

◆ has_create_public_threads()

bool dpp::role::has_create_public_threads ( ) const

True if has the create public threads permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the create public threads permission or is administrator.

◆ has_deafen_members()

bool dpp::role::has_deafen_members ( ) const

True if has the deafen members permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the deafen members permission or is administrator.

◆ has_embed_links()

bool dpp::role::has_embed_links ( ) const

True if has the embed links permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the embed links permission or is administrator.

◆ has_kick_members()

bool dpp::role::has_kick_members ( ) const

True if has the kick members permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the kick members permission or is administrator.

◆ has_manage_channels()

bool dpp::role::has_manage_channels ( ) const

True if has the manage channels permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage channels permission or is administrator.

◆ has_manage_emojis_and_stickers()

bool dpp::role::has_manage_emojis_and_stickers ( ) const

True if has the manage emojis and stickers permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage emojis and stickers permission or is administrator.

◆ has_manage_events()

bool dpp::role::has_manage_events ( ) const

True if has the manage events permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage events permission or is administrator.

◆ has_manage_guild()

bool dpp::role::has_manage_guild ( ) const

True if has the manage guild permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage guild permission or is administrator.

◆ has_manage_messages()

bool dpp::role::has_manage_messages ( ) const

True if has the manage messages permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage messages permission or is administrator.

◆ has_manage_nicknames()

bool dpp::role::has_manage_nicknames ( ) const

True if has the manage nicknames permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage nicknames permission or is administrator.

◆ has_manage_roles()

bool dpp::role::has_manage_roles ( ) const

True if has the manage roles permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage roles permission or is administrator.

◆ has_manage_threads()

bool dpp::role::has_manage_threads ( ) const

True if has the manage threads permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage threads permission or is administrator.

◆ has_manage_webhooks()

bool dpp::role::has_manage_webhooks ( ) const

True if has the manage webhooks permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the manage webhooks permission or is administrator.

◆ has_mention_everyone()

bool dpp::role::has_mention_everyone ( ) const

True if has the mention @everyone and @here permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the mention @everyone and @here permission or is administrator.

◆ has_moderate_members()

bool dpp::role::has_moderate_members ( ) const

True if has the moderate users permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the moderate users permission or is administrator.

◆ has_move_members()

bool dpp::role::has_move_members ( ) const

True if has the move members permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the move members permission or is administrator.

◆ has_mute_members()

bool dpp::role::has_mute_members ( ) const

True if has the mute members permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the mute members permission or is administrator.

◆ has_priority_speaker()

bool dpp::role::has_priority_speaker ( ) const

True if has the priority speaker permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the priority speaker permission or is administrator.

◆ has_read_message_history()

bool dpp::role::has_read_message_history ( ) const

True if has the read message history permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the read message history permission or is administrator.

◆ has_request_to_speak()

bool dpp::role::has_request_to_speak ( ) const

True if has the request to speak permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the request to speak permission or is administrator.

◆ has_send_messages()

bool dpp::role::has_send_messages ( ) const

True if has the send messages permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the send messages permission or is administrator.

◆ has_send_messages_in_threads()

bool dpp::role::has_send_messages_in_threads ( ) const

True if has the send messages in threads permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the send messages in threads permission or is administrator.

◆ has_send_tts_messages()

bool dpp::role::has_send_tts_messages ( ) const

True if has the send TTS messages permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the send TTS messages permission or is administrator.

◆ has_send_voice_messages()

bool dpp::role::has_send_voice_messages ( ) const

True if has the send voice messages permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the send voice messages permission or is administrator.

◆ has_speak()

bool dpp::role::has_speak ( ) const

True if has the speak permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the speak permission or is administrator.

◆ has_stream()

bool dpp::role::has_stream ( ) const

True if has the stream permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the stream permission or is administrator.

◆ has_use_application_commands()

bool dpp::role::has_use_application_commands ( ) const

True if has the use application commands permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the use application commands permission or is administrator.

◆ has_use_clyde_ai()

bool dpp::role::has_use_clyde_ai ( ) const

True if has permission to use clyde AI.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the clyde AI permission or is administrator.

◆ has_use_embedded_activities()

bool dpp::role::has_use_embedded_activities ( ) const

True if has the start embedded activities permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the start embedded activities permission or is administrator.

◆ has_use_external_emojis()

bool dpp::role::has_use_external_emojis ( ) const

True if has the use external emojis permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the use external emojis permission or is administrator.

◆ has_use_external_sounds()

bool dpp::role::has_use_external_sounds ( ) const

True if has the use external sounds permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the use external sounds permission or is administrator.

◆ has_use_external_stickers()

bool dpp::role::has_use_external_stickers ( ) const

True if has the use external stickers permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the use external stickers permission or is administrator.

◆ has_use_soundboard()

bool dpp::role::has_use_soundboard ( ) const

True if has the use soundboard permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the use soundboard permission or is administrator.

◆ has_use_vad()

bool dpp::role::has_use_vad ( ) const

True if has use voice activity detection permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has use voice activity detection permission or is administrator.

◆ has_view_audit_log()

bool dpp::role::has_view_audit_log ( ) const

True if has the view audit log permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the view audit log permission or is administrator.

◆ has_view_channel()

bool dpp::role::has_view_channel ( ) const

True if has the view channel permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the view channel permission or is administrator.

◆ has_view_creator_monetization_analytics()

bool dpp::role::has_view_creator_monetization_analytics ( ) const

True if has the view creator monetization analytics permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the view creator monetization analytics permission or is administrator.

◆ has_view_guild_insights()

bool dpp::role::has_view_guild_insights ( ) const

True if has the view guild insights permission.

Note
Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
Returns
bool True if user has the view guild insights permission or is administrator.

◆ is_available_for_purchase()

bool dpp::role::is_available_for_purchase ( ) const

True if the role is available for purchase.

Returns
bool whether this role is available for purchase

◆ is_hoisted()

bool dpp::role::is_hoisted ( ) const

True if the role is hoisted.

Returns
bool Role appears separated from others in the member list

◆ is_linked()

bool dpp::role::is_linked ( ) const

True if the role is a linked role.

Returns
bool True if the role is a linked role

◆ is_managed()

bool dpp::role::is_managed ( ) const

True if the role is managed (belongs to a bot or application).

Returns
bool True if the role is managed (introduced for a bot or other application by Discord)

◆ is_mentionable()

bool dpp::role::is_mentionable ( ) const

True if the role is mentionable.

Returns
bool Role is mentionable

◆ is_premium_subscriber()

bool dpp::role::is_premium_subscriber ( ) const

True if the role is the guild's Booster role.

Returns
bool whether the role is the premium subscriber, AKA "boost", role for the guild

◆ is_selectable_in_prompt()

bool dpp::role::is_selectable_in_prompt ( ) const

True if the role can be selected by members in an onboarding prompt.

Returns
bool True if the role can be selected by members in an onboarding prompt

◆ load_image() [1/2]

role& dpp::role::load_image ( const std::byte *  data,
uint32_t  size,
const image_type  type 
)

Load a role icon.

Parameters
dataImage binary data
sizeSize of the image.
typeType of image. It can be one of i_gif, i_jpg or i_png.
Returns
emoji& Reference to self

◆ load_image() [2/2]

role& dpp::role::load_image ( std::string_view  image_blob,
const image_type  type 
)

Load a role icon.

Parameters
image_blobImage binary data
typeType of image. It can be one of i_gif, i_jpg or i_png.
Returns
emoji& Reference to self

◆ operator!=() [1/2]

constexpr bool dpp::managed::operator!= ( const managed other) const
inlineconstexprnoexceptinherited

Comparison operator for comparing two managed objects by id.

Parameters
otherOther object to compare against
Returns
true objects are not the same id
false objects are the same id

◆ operator!=() [2/2]

bool dpp::role::operator!= ( const role other) const
inline

Operator not equals, used for checking if a role is ranked equal to another.

Parameters
otherrole to compare
Returns
true if is not equal to other

◆ operator=() [1/2]

role& dpp::role::operator= ( const role rhs)
default

Copy another role object.

Parameters
rhsRole object to copy

◆ operator=() [2/2]

role& dpp::role::operator= ( role &&  rhs)
default

Move from another role object.

Parameters
rhsRole object to copy

◆ operator==() [1/2]

constexpr bool dpp::managed::operator== ( const managed other) const
inlineconstexprnoexceptinherited

Comparison operator for comparing two managed objects by id.

Parameters
otherOther object to compare against
Returns
true objects are the same id
false objects are not the same id

◆ operator==() [2/2]

bool dpp::role::operator== ( const role other) const
inline

Operator equals, used for checking if a role is ranked equal to another.

Parameters
otherrole to compare
Returns
true if is equal to other

◆ set_bot_id()

role& dpp::role::set_bot_id ( snowflake  b)

Set the bot ID.

Parameters
bBot ID to set
Returns
role& reference to self

◆ set_color()

role& dpp::role::set_color ( uint32_t  c)

Set the color.

Parameters
cColour to set
Note
This is an alias of role::set_colour for American spelling.
Returns
role& reference to self

◆ set_colour()

role& dpp::role::set_colour ( uint32_t  c)

Set the colour.

Parameters
cColour to set
Note
There is an americanised version of this method, role::set_color().
Returns
role& reference to self

◆ set_flags()

role& dpp::role::set_flags ( uint8_t  f)

Set the flags.

Parameters
fFlags to set from dpp::role_flags
Returns
role& reference to self

◆ set_guild_id()

role& dpp::role::set_guild_id ( snowflake  gid)

Set the guild ID.

Parameters
gidGuild ID to set
Returns
role& reference to self

◆ set_integration_id()

role& dpp::role::set_integration_id ( snowflake  i)

Set the integration ID.

Parameters
iIntegration ID to set
Returns
role& reference to self

◆ set_name()

role& dpp::role::set_name ( const std::string &  n)

Set the name of the role. Maximum length: 100 Minimum length: 1.

Parameters
nName to set
Returns
role& reference to self
Exceptions
dpp::exceptionthrown if role length is less than 1 character

◆ to_json()

auto dpp::json_interface< role >::to_json ( bool  with_id = false) const
inlineinherited

Convert object to nlohmann::json.

Parameters
with_idWhether to include the ID or not
Note
Some fields are conditionally filled, do not rely on all fields being present
Returns
json Json built from the structure

◆ to_json_impl()

virtual json dpp::role::to_json_impl ( bool  with_id = false) const
protectedvirtual

Build a json from this object.

Parameters
with_idtrue if the ID is to be included in the json
Returns
The json of the role

Friends And Related Function Documentation

◆ json_interface< role >

friend struct json_interface< role >
friend

◆ operator<

bool operator< ( const role lhs,
const role rhs 
)
friend

Operator less than, used for checking if a role is below another.

Parameters
lhsfirst role to compare
rhssecond role to compare
Returns
true if lhs is less than rhs

◆ operator>

bool operator> ( const role lhs,
const role rhs 
)
friend

Operator greater than, used for checking if a role is above another.

Parameters
lhsfirst role to compare
rhssecond role to compare
Returns
true if lhs is greater than rhs

Member Data Documentation

◆ bot_id

snowflake dpp::role::bot_id {}

Bot id if any. (e.g. role is a bot's role created when it was invited)

◆ colour

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.

◆ flags

uint8_t dpp::role::flags {0}

Role flags from dpp::role_flags.

◆ guild_id

snowflake dpp::role::guild_id {0}

Guild ID.

◆ icon

utility::icon dpp::role::icon {}

The role icon.

◆ id

snowflake dpp::managed::id = {}
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.

◆ integration_id

snowflake dpp::role::integration_id {}

Integration id if any. (e.g. role is a bot's role created when it was invited).

◆ name

std::string dpp::role::name {}

Role name Between 1 and 100 characters.

◆ permissions

permission dpp::role::permissions {}

Role permissions bitmask values from dpp::permissions.

◆ position

uint8_t dpp::role::position {0}

Role position.

◆ subscription_listing_id

snowflake dpp::role::subscription_listing_id {}

The id of the role's subscription sku and listing.

◆ unicode_emoji

std::string dpp::role::unicode_emoji {}

The unicode emoji used for the role's icon.

Note
This can be an empty string.
D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0