From 4777153375e93fb896505d2e1438e3336fdbcad4 Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Sun, 29 Oct 2023 14:12:36 +0000 Subject: [PATCH] refactor: removed inner_select_emoji and moved inner_emoji to emoji.h --- include/dpp/emoji.h | 37 +++++++++++++++++++++++++++ include/dpp/message.h | 58 ++++++------------------------------------- 2 files changed, 44 insertions(+), 51 deletions(-) diff --git a/include/dpp/emoji.h b/include/dpp/emoji.h index fff307d0f4..e06a431d56 100644 --- a/include/dpp/emoji.h +++ b/include/dpp/emoji.h @@ -47,6 +47,43 @@ enum emoji_flags : uint8_t { e_available = 0b00001000, }; +/** + * @brief An emoji for a component (select menus included). + * + * To set an emoji on your button, you must set one of either the name or id fields. + * The easiest way is to use the dpp::component::set_emoji method. + * + * @note This is a **very** scaled down version of dpp::emoji, we advise that you refrain from using this. + */ +struct component_emoji { + /** + * @brief The name of the emoji. + * + * For built in unicode emojis, set this to the + * actual unicode value of the emoji e.g. "😄" + * and not for example ":smile:" + */ + std::string name{""}; + + /** + * @brief The emoji ID value for emojis that are custom + * ones belonging to a guild. + * + * The same rules apply as with other emojis, + * that the bot must be on the guild where the emoji resides + * and it must be available for use + * (e.g. not disabled due to lack of boosts, etc) + */ + dpp::snowflake id{0}; + + /** + * @brief Is the emoji animated? + * + * @note Only applies to custom emojis. + */ + bool animated{false}; +} + /** * @brief Represents an emoji for a dpp::guild */ diff --git a/include/dpp/message.h b/include/dpp/message.h index f877bb2db6..4b44d4c5cd 100644 --- a/include/dpp/message.h +++ b/include/dpp/message.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -135,35 +136,11 @@ struct DPP_EXPORT select_option : public json_interface { * @brief True if option is the default option */ bool is_default; + /** - * @brief Emoji definition. To set an emoji on your button - * you must set one of either the name or id fields. - * The easiest way is to use the component::set_emoji - * method. + * @brief The emoji for the select option. */ - struct inner_select_emoji { - /** - * @brief Set the name field to the name of the emoji. - * For built in unicode emojis, set this to the - * actual unicode value of the emoji e.g. "😄" - * and not for example ":smile:" - */ - std::string name; - /** - * @brief The emoji ID value for emojis that are custom - * ones belonging to a guild. The same rules apply - * as with other emojis, that the bot must be on - * the guild where the emoji resides and it must - * be available for use (e.g. not disabled due to - * lack of boosts etc) - */ - dpp::snowflake id = 0; - /** - * @brief True if the emoji is animated. Only applies to - * custom emojis. - */ - bool animated = false; - } emoji; + inner_emoji emoji; /** * @brief Construct a new select option object @@ -340,31 +317,10 @@ class DPP_EXPORT component : public json_interface { */ std::variant value; - /** Emoji definition. To set an emoji on your button - * you must set one of either the name or id fields. - * The easiest way is to use the component::set_emoji - * method. + /** + * @brief The emoji for this component. */ - struct inner_emoji { - /** Set the name field to the name of the emoji. - * For built in unicode emojis, set this to the - * actual unicode value of the emoji e.g. "😄" - * and not for example ":smile:" - */ - std::string name; - /** The emoji ID value for emojis that are custom - * ones belonging to a guild. The same rules apply - * as with other emojis, that the bot must be on - * the guild where the emoji resides and it must - * be available for use (e.g. not disabled due to - * lack of boosts etc) - */ - dpp::snowflake id; - /** True if the emoji is animated. Only applies to - * custom emojis. - */ - bool animated; - } emoji; + inner_emoji emoji; /** Constructor */