Represents an emoji for a dpp::guild. More...
#include "emoji.h"
Public Member Functions | |
emoji ()=default | |
Construct a new emoji object. More... | |
emoji (const emoji &rhs)=default | |
Copy constructor, copies another emoji's data. More... | |
emoji (const std::string_view name, const snowflake id=0, const uint8_t flags=0) | |
Construct a new emoji object with name, ID and flags. More... | |
emoji (emoji &&rhs) noexcept=default | |
Move constructor, moves another emoji's data to this. More... | |
~emoji () override=default | |
Destroy the emoji object. More... | |
template<typename U = T, typename = decltype(std::declval<U&>().to_json_impl(bool{}))> | |
std::string | build_json (bool with_id=false) const |
Convert object to json string. More... | |
template<typename U = T, typename = decltype(std::declval<U&>().fill_from_json_impl(std::declval<nlohmann::json*>()))> | |
T & | fill_from_json (nlohmann::json *j) |
Convert object from nlohmann::json. More... | |
std::string | format () const |
Format to name if unicode, name:id if has id or a:name:id if animated. More... | |
constexpr double | get_creation_time () const noexcept |
Get the creation time of this object according to Discord. More... | |
std::string | get_mention () const |
Get the mention/ping for the emoji. More... | |
std::string | get_url (uint16_t size=0, const image_type format=i_png, bool prefer_animated=true) const |
Get the custom emoji url. More... | |
bool | is_animated () const |
Emoji is animated. More... | |
bool | is_available () const |
Is available. More... | |
bool | is_managed () const |
Emoji is managed. More... | |
emoji & | load_image (const std::byte *data, uint32_t size, const image_type type) |
Load an image into the object. More... | |
emoji & | load_image (std::string_view image_blob, const image_type type) |
Load an image into the object. More... | |
constexpr bool | operator!= (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
emoji & | operator= (const emoji &rhs)=default |
Copy assignment operator, copies another emoji's data. More... | |
emoji & | operator= (emoji &&rhs) noexcept=default |
Move constructor, moves another emoji's data to this. More... | |
constexpr bool | operator== (const managed &other) const noexcept |
Comparison operator for comparing two managed objects by id. More... | |
bool | requires_colons () const |
Emoji requires colons. More... | |
template<typename U = T, typename = decltype(std::declval<U&>().to_json_impl(bool{}))> | |
auto | to_json (bool with_id=false) const |
Convert object to nlohmann::json. More... | |
Static Public Member Functions | |
static std::string | get_mention (std::string_view name, snowflake id, bool is_animated=false) |
Create a mentionable emoji. More... | |
Public Attributes | |
uint8_t | flags {0} |
Flags for the emoji from dpp::emoji_flags. More... | |
snowflake | id = {} |
Unique ID of object set by Discord. More... | |
utility::image_data | image_data |
Image data for the emoji, if uploading. More... | |
std::string | name {} |
Emoji name. More... | |
std::vector< snowflake > | roles |
Roles allowed to use this emoji. More... | |
snowflake | user_id |
The id of the user that created this emoji. More... | |
Protected Member Functions | |
emoji & | fill_from_json_impl (nlohmann::json *j) |
Read class values from json object. More... | |
json | to_json_impl (bool with_id=false) const |
Build the json for this object. More... | |
Friends | |
struct | json_interface< emoji > |
Represents an emoji for a dpp::guild.
|
default |
Construct a new emoji object.
dpp::emoji::emoji | ( | const std::string_view | name, |
const snowflake | id = 0 , |
||
const uint8_t | flags = 0 |
||
) |
Construct a new emoji object with name, ID and flags.
name | The emoji's name |
id | ID, if it has one (unicode does not) |
flags | Emoji flags (emoji_flags) |
References dpp::e_require_colons, and flags.
|
default |
Copy constructor, copies another emoji's data.
rhs | Emoji to copy |
|
defaultnoexcept |
Move constructor, moves another emoji's data to this.
rhs | Emoji to move from |
|
overridedefault |
Destroy the emoji object.
|
inlineinherited |
Convert object to json string.
with_id | Whether to include the ID or not |
Referenced by dpp::cluster::create_webhook(), dpp::cluster::guild_ban_add(), dpp::cluster::guild_ban_delete(), dpp::cluster::guild_command_edit_permissions(), dpp::cluster::guild_create(), dpp::cluster::guild_get_integrations(), dpp::cluster::guild_get_preview(), dpp::cluster::guild_get_vanity(), and dpp::cluster::roles_get().
|
inlineinherited |
Convert object from nlohmann::json.
j | nlohmann::json object |
Referenced by dpp::invite::fill_from_json_impl(), dpp::thread::fill_from_json_impl(), dpp::scheduled_event::fill_from_json_impl(), dpp::from_json(), dpp::message::get_url(), and dpp::interaction_response::interaction_response().
|
protected |
Read class values from json object.
j | A json object to read from |
References dpp::e_animated, and flags.
std::string dpp::emoji::format | ( | ) | const |
Format to name if unicode, name:id if has id or a:name:id if animated.
|
inlineconstexprnoexceptinherited |
Get the creation time of this object according to Discord.
std::string dpp::emoji::get_mention | ( | ) | const |
Get the mention/ping for the emoji.
|
static |
Create a mentionable emoji.
name | The name of the emoji. |
id | The ID of the emoji. |
is_animated | is emoji animated. |
std::string dpp::emoji::get_url | ( | uint16_t | size = 0 , |
const image_type | format = i_png , |
||
bool | prefer_animated = true |
||
) | const |
Get the custom emoji url.
size | The size of the emoji in pixels. It can be any power of two between 16 and 4096, otherwise the default sized emoji is returned. |
format | The format to use for the emoji. It can be one of i_webp , i_jpg , i_png or i_gif . When passing i_gif , it returns an empty string for non-animated emojis. Consider using the prefer_animated parameter instead. |
prefer_animated | Whether you prefer gif format. If true, it'll return gif format whenever the emoji is available as animated. |
bool dpp::emoji::is_animated | ( | ) | const |
Emoji is animated.
Referenced by dpp::poll::add_answer(), is_available(), and load_image().
bool dpp::emoji::is_available | ( | ) | const |
Is available.
References is_animated(), and name.
bool dpp::emoji::is_managed | ( | ) | const |
Emoji is managed.
References dpp::err_icon_size, and MAX_EMOJI_SIZE.
emoji & dpp::emoji::load_image | ( | const std::byte * | data, |
uint32_t | size, | ||
const image_type | type | ||
) |
Load an image into the object.
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 . |
dpp::length_exception | Image content exceeds discord maximum of 256 kilobytes |
emoji & dpp::emoji::load_image | ( | std::string_view | image_blob, |
const image_type | type | ||
) |
Load an image into the object.
image_blob | Image binary data |
type | Type of image. It can be one of i_gif , i_jpg or i_png . |
dpp::length_exception | Image content exceeds discord maximum of 256 kilobytes |
References dpp::utility::emoji_mention(), is_animated(), and name.
|
inlineconstexprnoexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
Copy assignment operator, copies another emoji's data.
rhs | Emoji to copy |
Move constructor, moves another emoji's data to this.
rhs | Emoji to move from |
|
inlineconstexprnoexceptinherited |
Comparison operator for comparing two managed objects by id.
other | Other object to compare against |
bool dpp::emoji::requires_colons | ( | ) | const |
Emoji requires colons.
|
inlineinherited |
Convert object to nlohmann::json.
with_id | Whether to include the ID or not |
Referenced by dpp::cluster::delete_webhook_with_token(), and dpp::onboarding_prompt::onboarding_prompt().
|
protected |
Build the json for this object.
with_id | include the id in the JSON |
References dpp::e_managed, and flags.
|
friend |
uint8_t dpp::emoji::flags {0} |
Flags for the emoji from dpp::emoji_flags.
Referenced by emoji(), fill_from_json_impl(), and to_json_impl().
|
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().
utility::image_data dpp::emoji::image_data |
Image data for the emoji, if uploading.
std::string dpp::emoji::name {} |
Emoji name.
Referenced by dpp::poll::add_answer(), is_available(), load_image(), dpp::component::set_disabled(), and dpp::select_option::set_label().
std::vector<snowflake> dpp::emoji::roles |
Roles allowed to use this emoji.
snowflake dpp::emoji::user_id |
The id of the user that created this emoji.