| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
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...

`#include <role.h>`

Inheritance diagram for dpp::role:
[legend]
Collaboration diagram for dpp::role:
[legend]

## Public Member Functions

| role ()=default
| Construct a new role object.
| role (const role &rhs)=default
| Construct a new role object.
| role (role &&rhs)=default
| Construct a new role object.
virtual | ~role ()=default
| Destroy the role object.
std::string | build_json (bool with_id=false) const
| Convert object to json string.
role & | fill_from_json (nlohmann::json *j)
| Convert object from nlohmann::json.
role & | fill_from_json (snowflake guild_id, nlohmann::json *j)
| Fill this role from json.
constexpr double | get_creation_time () const noexcept
| Get the creation time of this object according to Discord.
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.
members_container | get_members () const
| Get guild members who have this role.
std::string | get_mention () const
| Get the mention/ping for the role.
bool | has_add_reactions () const
| True if has the add reactions permission.
bool | has_administrator () const
| True if has the administrator permission.
bool | has_attach_files () const
| True if has the attach files permission.
bool | has_ban_members () const
| True if has the ban members permission.
bool | has_bypass_slowmode () const
| True if has the bypass slow mode permission.
bool | has_change_nickname () const
| True if has the change nickname permission.
bool | has_connect () const
| True if has the connect voice permission.
bool | has_create_events () const
| True if has the create events permission.
bool | has_create_guild_expressions () const
| True if has the create guild expressions permission.
bool | has_create_instant_invite () const
| True if has create instant invite permission.
bool | has_create_private_threads () const
| True if has the create private threads permission.
bool | has_create_public_threads () const
| True if has the create public threads permission.
bool | has_deafen_members () const
| True if has the deafen members permission.
bool | has_embed_links () const
| True if has the embed links permission.
bool | has_kick_members () const
| True if has the kick members permission.
bool | has_manage_channels () const
| True if has the manage channels permission.
bool | has_manage_emojis_and_stickers () const
| True if has the manage emojis and stickers permission.
bool | has_manage_events () const
| True if has the manage events permission.
bool | has_manage_guild () const
| True if has the manage guild permission.
bool | has_manage_messages () const
| True if has the manage messages permission.
bool | has_manage_nicknames () const
| True if has the manage nicknames permission.
bool | has_manage_roles () const
| True if has the manage roles permission.
bool | has_manage_threads () const
| True if has the manage threads permission.
bool | has_manage_webhooks () const
| True if has the manage webhooks permission.
bool | has_mention_everyone () const
| True if has the mention @everyone and @here permission.
bool | has_moderate_members () const
| True if has the moderate users permission.
bool | has_move_members () const
| True if has the move members permission.
bool | has_mute_members () const
| True if has the mute members permission.
bool | has_pin_messages () const
| True if has permission to use pin messages.
bool | has_priority_speaker () const
| True if has the priority speaker permission.
bool | has_read_message_history () const
| True if has the read message history permission.
bool | has_request_to_speak () const
| True if has the request to speak permission.
bool | has_send_messages () const
| True if has the send messages permission.
bool | has_send_messages_in_threads () const
| True if has the send messages in threads permission.
bool | has_send_polls () const
| True if has the send polls permission.
bool | has_send_tts_messages () const
| True if has the send TTS messages permission.
bool | has_send_voice_messages () const
| True if has the send voice messages permission.
bool | has_speak () const
| True if has the speak permission.
bool | has_stream () const
| True if has the stream permission.
bool | has_use_application_commands () const
| True if has the use application commands permission.
bool | has_use_clyde_ai () const
| True if has permission to use clyde AI.
bool | has_use_embedded_activities () const
| True if has the start embedded activities permission.
bool | has_use_external_apps () const
| True if has the use external apps permission.
bool | has_use_external_emojis () const
| True if has the use external emojis permission.
bool | has_use_external_sounds () const
| True if has the use external sounds permission.
bool | has_use_external_stickers () const
| True if has the use external stickers permission.
bool | has_use_soundboard () const
| True if has the use soundboard permission.
bool | has_use_vad () const
| True if has use voice activity detection permission.
bool | has_view_audit_log () const
| True if has the view audit log permission.
bool | has_view_channel () const
| True if has the view channel permission.
bool | has_view_creator_monetization_analytics () const
| True if has the view creator monetization analytics permission.
bool | has_view_guild_insights () const
| True if has the view guild insights permission.
bool | is_available_for_purchase () const
| True if the role is available for purchase.
bool | is_hoisted () const
| True if the role is hoisted.
bool | is_linked () const
| True if the role is a linked role.
bool | is_managed () const
| True if the role is managed (belongs to a bot or application).
bool | is_mentionable () const
| True if the role is mentionable.
bool | is_premium_subscriber () const
| True if the role is the guild's Booster role.
bool | is_selectable_in_prompt () const
| True if the role can be selected by members in an onboarding prompt.
role & | load_image (const std::byte *data, uint32_t size, const image_type type)
| Load a role icon.
role & | load_image (std::string_view image_blob, const image_type type)
| Load a role icon.
constexpr bool | operator!= (const managed &other) const noexcept
| Comparison operator for comparing two managed objects by id.
bool | operator!= (const role &other) const
| Operator not equals, used for checking if a role is ranked equal to another.
role & | operator= (const role &rhs)=default
| Copy another role object.
role & | operator= (role &&rhs)=default
| Move from another role object.
constexpr bool | operator== (const managed &other) const noexcept
| Comparison operator for comparing two managed objects by id.
bool | operator== (const role &other) const
| Operator equals, used for checking if a role is ranked equal to another.
role & | set_bot_id (snowflake b)
| Set the bot ID.
role & | set_color (uint32_t c)
| Set the color.
role & | set_colour (uint32_t c)
| Set the colour.
role & | set_flags (uint8_t f)
| Set the flags.
role & | set_guild_id (snowflake gid)
| Set the guild ID.
role & | set_integration_id (snowflake i)
| Set the integration ID.
role & | set_name (const std::string &n)
| Set the name of the role. Maximum length: 100 Minimum length: 1.
auto | to_json (bool with_id=false) const
| Convert object to nlohmann::json.

## Static Public Member Functions

static std::string | get_mention (const snowflake &id)
| Create a mentionable role.

## Public Attributes

snowflake | bot_id {}
| Bot id if any. (e.g. role is a bot's role created when it was invited).
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.
uint8_t | flags {0}
| Role flags from dpp::role_flags.
snowflake | guild_id {0}
| Guild ID.
utility::icon | icon {}
| The role icon.
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.
snowflake | integration_id {}
| Integration id if any. (e.g. role is a bot's role created when it was invited).
std::string | name {}
| Role name Between 1 and 100 characters.
permission | permissions {}
| Role permissions bitmask values from dpp::permissions.
uint8_t | position {0}
| Role position.
snowflake | subscription_listing_id {}
| The id of the role's subscription sku and listing.
std::string | unicode_emoji {}
| The unicode emoji used for the role's icon.

## Protected Member Functions

role & | fill_from_json_impl (nlohmann::json *j)
| Fill this role from json.
virtual json | to_json_impl (bool with_id=false) const
| Build a json from this object.

## 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.
bool | operator> (const role &lhs, const role &rhs)
| Operator greater than, used for checking if a role is above another.

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

  rhs | Role object to copy

## ◆ role() [3/3]

dpp::role::role | ( | role && | rhs | ) |

default

Construct a new role object.

Parameters

  rhs | Role object to move

## ◆ ~role()

virtual dpp::role::~role | ( |  | ) |

virtual default

Destroy the role object.

## Member Function Documentation

## ◆ build_json()

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

inline inherited

Convert object to json string.

Parameters

  with_id | Whether 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 | ) |

inline inherited

Convert object from nlohmann::json.

Parameters

  j | nlohmann::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_id | the guild id to place in the json
  j | The 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

  j | The json data

Returns
  A reference to self

## ◆ get_creation_time()

double dpp::managed::get_creation_time | ( |  | ) | const

inline constexpr noexcept inherited

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

  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.

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]

std::string dpp::role::get_mention | ( | const snowflake & | id | ) |

static

Create a mentionable role.

Parameters

  id | The 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_bypass_slowmode()

bool dpp::role::has_bypass_slowmode | ( |  | ) | const

True if has the bypass slow mode 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 bypass slow mode 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_events()

bool dpp::role::has_create_events | ( |  | ) | const

True if has the create events permission.

Note
  Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
  Not yet available to developers.

Returns
  bool True if user has the create events permission or is administrator.

## ◆ has_create_guild_expressions()

bool dpp::role::has_create_guild_expressions | ( |  | ) | const

True if has the create guild expressions permission.

Note
  Having the administrator permission causes this method to always return true Channel specific overrides may apply to permissions.
  Not yet available to developers.

Returns
  bool True if user has the create guild expressions 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_pin_messages()

bool dpp::role::has_pin_messages | ( |  | ) | const

True if has permission to use pin messages.

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 Pin Messages 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_polls()

bool dpp::role::has_send_polls | ( |  | ) | const

True if has the send polls 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 polls 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_apps()

bool dpp::role::has_use_external_apps | ( |  | ) | const

True if has the use external apps 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 apps 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

  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.

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_blob | Image binary data
  type | Type of image. It can be one of i_gif, i_jpg or i_png.

Returns
  emoji& Reference to self

## ◆ operator!=() [1/2]

bool dpp::managed::operator!= | ( | const managed & | other | ) | const

inline constexpr noexcept inherited

Comparison operator for comparing two managed objects by id.

Parameters

  other | Other 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

  other | role 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

  rhs | Role object to copy

## ◆ operator=() [2/2]

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

default

Move from another role object.

Parameters

  rhs | Role object to copy

## ◆ operator==() [1/2]

bool dpp::managed::operator== | ( | const managed & | other | ) | const

inline constexpr noexcept inherited

Comparison operator for comparing two managed objects by id.

Parameters

  other | Other 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

  other | role 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

  b | Bot ID to set

Returns
  role& reference to self

## ◆ set_color()

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

Set the color.

Parameters

  c | Colour 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

  c | Colour 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

  f | Flags 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

  gid | Guild ID to set

Returns
  role& reference to self

## ◆ set_integration_id()

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

Set the integration ID.

Parameters

  i | Integration 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

  n | Name to set

Returns
  role& reference to self

Exceptions

  dpp::exception | thrown if role length is less than 1 character

## ◆ to_json()

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

inline inherited

Convert object to nlohmann::json.

Parameters

  with_id | Whether 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

protected virtual

Build a json from this object.

Parameters

  with_id | true if the ID is to be included in the json

Returns
  The json of the role

## Friends And Related Symbol 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

  lhs | first role to compare
  rhs | second 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

  lhs | first role to compare
  rhs | second 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.

Warning
  multiple roles can have the same position number. As a result, comparing roles by position alone can lead to subtle bugs when checking for role hierarchy. The recommended and correct way to compare for roles in the hierarchy is using the comparison operators on the role objects themselves.

## ◆ 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.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0