diff --git a/include/dpp/guild.h b/include/dpp/guild.h index fd6a3d8a98..755b53befe 100644 --- a/include/dpp/guild.h +++ b/include/dpp/guild.h @@ -35,125 +35,302 @@ namespace dpp { class channel; +/* Note from Archie: I'd like to move this soon (dpp::guild::region) and allow users to use a region enum. + * This would make it easier for people to be able to alter a channel region without having to get the text right. + */ + /** * @brief Represents voice regions for guilds and channels. * @deprecated Deprecated in favour of per-channel regions. - * Please use channel::rtc_region instead. + * Please use dpp::channel::rtc_region instead. */ enum region : uint8_t { - r_brazil, //!< Brazil - r_central_europe, //!< Central Europe - r_hong_kong, //!< Hong Kong - r_india, //!< India - r_japan, //!< Japan - r_russia, //!< Russia - r_singapore, //!< Singapore - r_south_africa, //!< South Africa - r_sydney, //!< Sydney - r_us_central, //!< US Central - r_us_east, //!< US East Coast - r_us_south, //!< US South - r_us_west, //!< US West Coast - r_western_europe //!< Western Europe + /** + * @brief Brazil + */ + r_brazil, + + /** + * @brief Central Europe + */ + r_central_europe, + + /** + * @brief Hong Kong + */ + r_hong_kong, + + /** + * @brief India + */ + r_india, + + /** + * @brief Japan + */ + r_japan, + + /** + * @brief Russia + */ + r_russia, + + /** + * @brief Singapore + */ + r_singapore, + + /** + * @brief South Africa + */ + r_south_africa, + + /** + * @brief Sydney + */ + r_sydney, + + /** + * @brief US Central + */ + r_us_central, + + /** + * @brief US East Coast + */ + r_us_east, + + /** + * @brief US South + */ + r_us_south, + + /** + * @brief US West Coast + */ + r_us_west, + + /** + * @brief Western Europe + */ + r_western_europe }; /** * @brief The various flags that represent the status of a dpp::guild object */ enum guild_flags : uint32_t { - /** Large guild */ - g_large = 0b00000000000000000000000000000001, - /** Unavailable guild (inaccessible due to an outage) */ - g_unavailable = 0b00000000000000000000000000000010, - /** Guild has widget enabled */ - g_widget_enabled = 0b00000000000000000000000000000100, - /** Guild can have an invite splash image */ - g_invite_splash = 0b00000000000000000000000000001000, - /** Guild can have VIP regions */ - g_vip_regions = 0b00000000000000000000000000010000, - /** Guild can have a vanity url */ - g_vanity_url = 0b00000000000000000000000000100000, - /** Guild is verified */ - g_verified = 0b00000000000000000000000001000000, - /** Guild is partnered */ - g_partnered = 0b00000000000000000000000010000000, - /** Community features enabled */ - g_community = 0b00000000000000000000000100000000, - /** Guild has enabled role subscriptions */ - g_role_subscription_enabled = 0b00000000000000000000001000000000, - /** Guild has access to create announcement channels */ - g_news = 0b00000000000000000000010000000000, - /** Guild is discoverable in discovery */ - g_discoverable = 0b00000000000000000000100000000000, - /** Guild is featureable */ - g_featureable = 0b00000000000000000001000000000000, - /** Guild can have an animated icon (doesn't mean it actually has one though) */ - g_animated_icon = 0b00000000000000000010000000000000, - /** Guild can have a banner image */ - g_banner = 0b00000000000000000100000000000000, - /** Guild has a welcome screen */ - g_welcome_screen_enabled = 0b00000000000000001000000000000000, - /** Guild has a member verification gate */ - g_member_verification_gate = 0b00000000000000010000000000000000, - /** Guild has a preview */ - g_preview_enabled = 0b00000000000000100000000000000000, - /** Guild join notifications are off */ - g_no_join_notifications = 0b00000000000001000000000000000000, - /** Guild boost notifications are off */ - g_no_boost_notifications = 0b00000000000010000000000000000000, - /** Guild has an actual animated icon (set by the icon hash starting with 'a_') */ - g_has_animated_icon = 0b00000000000100000000000000000000, - /** Guild has an actual animated banner (set by the icon hash starting with 'a_') */ - g_has_animated_banner = 0b00000000001000000000000000000000, - /** Guild setup tips are off */ - g_no_setup_tips = 0b00000000010000000000000000000000, - /** "Wave to say hi" sticker prompt buttons are off */ - g_no_sticker_greeting = 0b00000000100000000000000000000000, - /** guild has enabled monetization */ - g_monetization_enabled = 0b00000001000000000000000000000000, - /** guild has increased custom sticker slots */ - g_more_stickers = 0b00000010000000000000000000000000, - /** Guild has enabled the role subscription promo page */ - g_creator_store_page_enabled = 0b00000100000000000000000000000000, - /** guild is able to set role icons */ - g_role_icons = 0b00001000000000000000000000000000, - /** guild has access to the seven day archive time for threads + /** + * @brief Large guild + */ + g_large = 0b00000000000000000000000000000001, + + /** + * @brief Unavailable guild (inaccessible due to an outage) + */ + g_unavailable = 0b00000000000000000000000000000010, + + /** + * @brief Guild has widget enabled + */ + g_widget_enabled = 0b00000000000000000000000000000100, + + /** + * @brief Guild can have an invite splash image + */ + g_invite_splash = 0b00000000000000000000000000001000, + + /** + * @brief Guild can have VIP regions + */ + g_vip_regions = 0b00000000000000000000000000010000, + + /** + * @brief Guild can have a vanity url + */ + g_vanity_url = 0b00000000000000000000000000100000, + + /** + * @brief Guild is verified + */ + g_verified = 0b00000000000000000000000001000000, + + /** + * @brief Guild is partnered + */ + g_partnered = 0b00000000000000000000000010000000, + + /** + * @brief Community features enabled + */ + g_community = 0b00000000000000000000000100000000, + + /** + * @brief Guild has enabled role subscriptions + */ + g_role_subscription_enabled = 0b00000000000000000000001000000000, + + /** + * @brief Guild has access to create announcement channels + */ + g_news = 0b00000000000000000000010000000000, + + /** + * @brief Guild is discoverable in discovery + */ + g_discoverable = 0b00000000000000000000100000000000, + + /** + * @brief Guild is featureable + */ + g_featureable = 0b00000000000000000001000000000000, + + /** + * @brief Guild can have an animated icon (doesn't mean it actually has one though) + */ + g_animated_icon = 0b00000000000000000010000000000000, + + /** + * @brief Guild can have a banner image + */ + g_banner = 0b00000000000000000100000000000000, + + /** + * @brief Guild has a welcome screen + */ + g_welcome_screen_enabled = 0b00000000000000001000000000000000, + + /** + * @brief Guild has a member verification gate + */ + g_member_verification_gate = 0b00000000000000010000000000000000, + + /** + * @brief Guild has a preview + */ + g_preview_enabled = 0b00000000000000100000000000000000, + + /** + * @brief Guild join notifications are off + */ + g_no_join_notifications = 0b00000000000001000000000000000000, + + /** + * @brief Guild boost notifications are off + */ + g_no_boost_notifications = 0b00000000000010000000000000000000, + + /** + * @brief Guild has an actual animated icon (set by the icon hash starting with 'a_') + */ + g_has_animated_icon = 0b00000000000100000000000000000000, + + /** + * @brief Guild has an actual animated banner (set by the icon hash starting with 'a_') + */ + g_has_animated_banner = 0b00000000001000000000000000000000, + + /** + * @brief Guild setup tips are off + */ + g_no_setup_tips = 0b00000000010000000000000000000000, + + /** + * @brief "Wave to say hi" sticker prompt buttons are off + */ + g_no_sticker_greeting = 0b00000000100000000000000000000000, + + /** + * @brief Guild has enabled monetization + */ + g_monetization_enabled = 0b00000001000000000000000000000000, + + /** + * @brief Guild has increased custom sticker slots + */ + g_more_stickers = 0b00000010000000000000000000000000, + + /** + * @brief Guild has enabled the role subscription promo page + */ + g_creator_store_page_enabled = 0b00000100000000000000000000000000, + + /** + * @brief Guild is able to set role icons + */ + g_role_icons = 0b00001000000000000000000000000000, + + /** + * @brief Guild has access to the seven day archive time for threads * @deprecated Removed by Discord */ - g_seven_day_thread_archive = 0b00010000000000000000000000000000, - /** guild has access to the three day archive time for threads + g_seven_day_thread_archive = 0b00010000000000000000000000000000, + + /** + * @brief Guild has access to the three day archive time for threads * @deprecated Removed by Discord */ - g_three_day_thread_archive = 0b00100000000000000000000000000000, - /** guild has enabled ticketed events */ - g_ticketed_events = 0b01000000000000000000000000000000, - /** guild can have channel banners + g_three_day_thread_archive = 0b00100000000000000000000000000000, + + /** + * @brief Guild has enabled ticketed events + */ + g_ticketed_events = 0b01000000000000000000000000000000, + + /** + * @brief Guild can have channel banners * @deprecated Removed by Discord */ - g_channel_banners = 0b10000000000000000000000000000000, + g_channel_banners = 0b10000000000000000000000000000000, }; /** * @brief Additional boolean flag values for guild, as guild_flags is full */ enum guild_flags_extra : uint16_t { - /** Guild has premium progress bar enabled */ - g_premium_progress_bar_enabled = 0b0000000000000001, - /** Guild can have an animated banner (doesn't mean it actually has one though) */ - g_animated_banner = 0b0000000000000010, - /** Guild has auto moderation */ - g_auto_moderation = 0b0000000000000100, - /** Guild has paused invites, preventing new users from joining */ - g_invites_disabled = 0b0000000000001000, - /** Guild has been set as support server of an app in the App Directory */ - g_developer_support_server = 0b0000000000010000, - /** Guild role subscription purchase and renewal notifications are off */ + /** + * @brief Guild has premium progress bar enabled + */ + g_premium_progress_bar_enabled = 0b0000000000000001, + + /** + * @brief Guild can have an animated banner (doesn't mean it actually has one though) + */ + g_animated_banner = 0b0000000000000010, + + /** + * @brief Guild has auto moderation + */ + g_auto_moderation = 0b0000000000000100, + + /** + * @brief Guild has paused invites, preventing new users from joining + */ + g_invites_disabled = 0b0000000000001000, + + /** + * @brief Guild has been set as support server of an app in the App Directory + */ + g_developer_support_server = 0b0000000000010000, + + /** + * @brief Guild role subscription purchase and renewal notifications are off + */ g_no_role_subscription_notifications = 0b0000000000100000, - /** Guild role subscription sticker reply buttons are off */ + + /** + * @brief Guild role subscription sticker reply buttons are off + */ g_no_role_subscription_notification_replies = 0b0000000001000000, - /** Guild has role subscriptions that can be purchased */ + + /** + * @brief Guild has role subscriptions that can be purchased + */ g_role_subscriptions_available_for_purchase = 0b0000000010000000, - /** Guild has disabled alerts for join raids in the configured safety alerts channel */ + + /** + * @brief Guild has disabled alerts for join raids in the configured safety alerts channel + */ g_raid_alerts_disabled = 0b0000000100000000, }; @@ -162,25 +339,63 @@ enum guild_flags_extra : uint16_t { * @note Use the setter functions in dpp::guild_member and do not toggle the bits yourself. */ enum guild_member_flags : uint16_t { - /** Member deafened in voice channels */ - gm_deaf = 0b0000000000000001, - /** Member muted in voice channels */ - gm_mute = 0b0000000000000010, - /** Member pending verification by membership screening */ - gm_pending = 0b0000000000000100, - /** Member has animated guild-specific avatar */ - gm_animated_avatar = 0b0000000000001000, - /** gm_deaf or gm_mute has been toggled */ - gm_voice_action = 0b0000000000010000, - /** Member has left and rejoined the guild */ + /** + * @brief Member deafened in voice channel + */ + gm_deaf = 0b0000000000000001, + + /** + * @brief Member muted in voice channels + */ + gm_mute = 0b0000000000000010, + + /** + * @brief Member pending verification by membership screening + */ + gm_pending = 0b0000000000000100, + + /** + * @brief Member has animated guild-specific avatar + */ + gm_animated_avatar = 0b0000000000001000, + + /** + * @brief gm_deaf or gm_mute has been toggled + */ + gm_voice_action = 0b0000000000010000, + + /** + * @brief Member has left and rejoined the guild + */ gm_did_rejoin = 0b0000000000100000, - /** Member has completed onboarding */ + + /** + * @brief Member has completed onboarding + */ gm_completed_onboarding = 0b0000000001000000, - /** Member is exempt from guild verification requirements */ + + /** + * @brief Member is exempt from guild verification requirements + */ gm_bypasses_verification = 0b0000000010000000, - /** Member has started onboarding */ + + /** + * @brief Member has started onboarding + */ gm_started_onboarding = 0b0000000100000000, - gm_roles_action = 0b0000001000000000, + + /** + * @brief Should change roles on next call to edit guild_member? + * @warning This is set by dpp::guild_member::add_role, dpp::guild_member::remove_role, and dpp::guild_member::set_roles. + * You should only ever use this value if you know what you're doing, otherwise stick to the three functions listed. + */ + gm_roles_action = 0b0000001000000000, + + /** + * @brief Should nicknames on next call to edit guild_member? + * @warning This is set by dpp::guild_member::set_nickname. + * You should only ever use this value if you know what you're doing, otherwise stick to the function listed. + */ gm_nickname_action = 0b0000010000000000, }; @@ -201,33 +416,58 @@ class DPP_EXPORT guild_member : public json_interface { json to_json_impl(bool with_id = false) const; protected: - /** Nickname, or empty string if they don't have a nickname on this guild */ + /** + * @brief Nickname, or empty string if they don't have a nickname on this guild + */ std::string nickname; - /** List of roles this user has on this guild */ + + /** + * @brief List of roles this user has on this guild + */ std::vector roles; - /** A set of flags built from the bitmask defined by dpp::guild_member_flags */ + + /** + * @brief A set of flags built from the bitmask defined by dpp::guild_member_flags + */ uint16_t flags; friend void from_json(const nlohmann::json& j, guild_member& gm); public: - /** Guild id */ + /** + * @brief Guild id + */ snowflake guild_id; - /** User id */ + + /** + * @brief User id + */ snowflake user_id; - /** User avatar (per-server avatar is a nitro only feature) */ + + /** + * @brief User avatar (per-server avatar is a nitro only feature) + */ utility::iconhash avatar; - /** timestamp of when the time out will be removed; until then, they cannot interact with the guild */ + /** + * @brief Timestamp of when the time out will be removed; until then, they cannot interact with the guild + */ time_t communication_disabled_until; - /** Date and time the user joined the guild */ + + /** + * @brief Date and time the user joined the guild. + */ time_t joined_at; - /** Boosting since */ + + /** + * @brief The Date and time the user started boosting. + */ time_t premium_since; /** Default constructor */ guild_member(); - /** Fill this object from a json object. + /** + * @brief Fill this object from a json object. * @param j The json object to get data from * @param g_id The guild id to associate the member with * @param u_id The user id to associate the member with @@ -440,7 +680,7 @@ class DPP_EXPORT guild_member : public json_interface { /** * @brief Defines a channel on a server's welcome screen */ -struct DPP_EXPORT welcome_channel: public json_interface { +struct DPP_EXPORT welcome_channel : public json_interface { protected: friend struct json_interface; @@ -461,13 +701,24 @@ struct DPP_EXPORT welcome_channel: public json_interface { json to_json_impl(bool with_id = false) const; public: - /// The description shown for the channel + /** + * @brief The description shown for the channel. + */ std::string description; - /// The emoji name if custom, the unicode character if standard, or null if no emoji is set + + /** + * @brief The emoji name if custom, the unicode character if standard, or null if no emoji is set. + */ std::string emoji_name; - /// The channel's id + + /** + * @brief The channel's id. + */ snowflake channel_id; - /// The emoji id, if the emoji is custom + + /** + * @brief The emoji id, if the emoji is custom. + */ snowflake emoji_id; /** @@ -501,7 +752,7 @@ struct DPP_EXPORT welcome_channel: public json_interface { /** * @brief Defines a server's welcome screen */ -struct DPP_EXPORT welcome_screen: public json_interface { +struct DPP_EXPORT welcome_screen : public json_interface { protected: friend struct json_interface; @@ -522,9 +773,14 @@ struct DPP_EXPORT welcome_screen: public json_interface { json to_json_impl(bool with_id = false) const; public: - /// The server description shown in the welcome screen + /** + * @brief The server description shown in the welcome screen + */ std::string description; - /// The channels shown in the welcome screen (max 5) + + /** + * @brief The channels shown in the welcome screen (max 5) + */ std::vector welcome_channels; /** @@ -552,14 +808,25 @@ struct DPP_EXPORT welcome_screen: public json_interface { * @note This is set by Discord, and cannot be set by any bot or user on the guild. */ enum guild_nsfw_level_t : uint8_t { - /// Default setting, not configured - nsfw_default = 0, - /// Explicit content may be in this guild - nsfw_explicit = 1, - /// Safe for work content only - nsfw_safe = 2, - /// Age restricted, 18+ - nsfw_age_restricted = 3 + /** + * @brief Default setting, not configured + */ + nsfw_default = 0, + + /** + * @brief Explicit content may be in this guild + */ + nsfw_explicit = 1, + + /** + * @brief Safe for work content only + */ + nsfw_safe = 2, + + /** + * @brief Age restricted, 18+ + */ + nsfw_age_restricted = 3 }; /** @@ -568,12 +835,20 @@ enum guild_nsfw_level_t : uint8_t { * partnered, official etc. */ enum guild_explicit_content_t : uint8_t { - /// media content will not be scanned - expl_disabled = 0, - /// media content sent by members without roles will be scanned - expl_members_without_roles = 1, - /// media content sent by all members will be scanned - expl_all_members = 2 + /** + * @brief Media content will not be scanned. + */ + expl_disabled = 0, + + /** + * @brief Media content sent by members without roles will be scanned. + */ + expl_members_without_roles = 1, + + /** + * @brief Media content sent by all members will be scanned. + */ + expl_all_members = 2 }; /** @@ -581,9 +856,14 @@ enum guild_explicit_content_t : uint8_t { * actions such as kick or ban. */ enum mfa_level_t : uint8_t { - /// MFA not elevated + /** + * @brief MFA not elevated + */ mfa_none = 0, - /// MFA elevated + + /** + * @brief MFA elevated. + */ mfa_elevated = 1 }; @@ -591,61 +871,109 @@ enum mfa_level_t : uint8_t { * @brief Guild verification level */ enum verification_level_t : uint8_t { - /// unrestricted - ver_none = 0, - /// must have verified email on account - ver_low = 1, - /// must be registered on Discord for longer than 5 minutes - ver_medium = 2, - /// must be a member of the server for longer than 10 minutes - ver_high = 3, - /// must have a verified phone number + /** + * @brief Unrestricted. + */ + ver_none = 0, + + /** + * @brief Must have verified email on account. + */ + ver_low = 1, + + /** + * @brief Must be registered on Discord for longer than 5 minutes. + */ + ver_medium = 2, + + /** + * @brief Must be a member of the server for longer than 10 minutes. + */ + ver_high = 3, + + /** + * @brief Must have a verified phone number. + */ ver_very_high = 4, }; /** * @brief Default message notification level */ -enum default_message_notification_t: uint8_t { - /// members will receive notifications for all messages by default +enum default_message_notification_t : uint8_t { + /** + * @brief Members will receive notifications for all messages by default. + */ dmn_all = 0, - /// members will receive notifications only for messages that \@mention them by default + + /** + * @brief Members will receive notifications only for messages that \@mention them by default. + */ dmn_only_mentions = 1, }; /** - * @brief Premium tier + * @brief The guild's premium tier. */ -enum guild_premium_tier_t: uint8_t { - /// guild has not unlocked any Server Boost perks +enum guild_premium_tier_t : uint8_t { + /** + * @brief Guild has not unlocked any Server Boost perks. + */ tier_none = 0, - /// guild has unlocked Server Boost level 1 perks + + /** + * @brief Guild has unlocked Server Boost level 1 perks. + */ tier_1 = 1, - /// guild has unlocked Server Boost level 2 perks + + /** + * @brief Guild has unlocked Server Boost level 2 perks. + */ tier_2 = 2, - /// guild has unlocked Server Boost level 3 perks + + /** + * @brief Guild has unlocked Server Boost level 3 perks. + */ tier_3 = 3, }; /** * @brief Voice AFK timeout values for guild::afk_timeout */ -enum guild_afk_timeout_t: uint8_t { - /// AFK timeout disabled +enum guild_afk_timeout_t : uint8_t { + /** + * @brief AFK timeout disabled + */ afk_off, - /// AFK timeout of 1 Minute + + /** + * @brief AFK timeout of 1 Minute + */ afk_60, - /// AFK timeout of 5 Minutes + + /** + * @brief AFK timeout of 5 Minutes + */ afk_300, - /// AFK timeout of 15 Minutes + + /** + * @brief AFK timeout of 15 Minutes + */ afk_900, - /// AFK timeout of 30 Minutes + + /** + * @brief AFK timeout of 30 Minutes + */ afk_1800, - /// AFK timeout of 1 Hour + + /** + * @brief AFK timeout of 1 Hour + */ afk_3600, }; -/** @brief Guild members container +/** + * @brief Guild members container */ typedef std::unordered_map members_container; @@ -671,10 +999,14 @@ class DPP_EXPORT guild : public managed, public json_interface { public: using json_interface::fill_from_json; - /** Guild name */ + /** + * @brief Guild name + */ std::string name; - /** Server description */ + /** + * @brief Server description + */ std::string description; /** @@ -685,74 +1017,114 @@ class DPP_EXPORT guild : public managed, public json_interface { */ std::string vanity_url_code; - /** Roles defined on this server */ + /** + * @brief Roles defined on this server + */ std::vector roles; - /** List of channels on this server */ + /** + * @brief List of channels on this server + */ std::vector channels; - /** List of threads on this server */ + /** + * @brief List of threads on this server + */ std::vector threads; - /** List of emojis - */ + /** + * @brief List of emojis + */ std::vector emojis; - /** List of members in voice channels in the guild. + /** + * @brief List of members in voice channels in the guild. */ std::map voice_members; - /** List of guild members. Note that when you first receive the - * guild create event, this may be empty or near empty. - * This depends upon your dpp::intents and the size of your bot. + /** + * @brief List of guild members. + * + * @note When you first receive the guild create event, + * this may be empty or near empty. This depends upon your + * dpp::intents and the size of your bot. * It will be filled by guild member chunk requests. */ members_container members; - /** Welcome screen + /** + * @brief Welcome screen */ dpp::welcome_screen welcome_screen; - /** Guild icon */ + /** + * @brief Guild icon + */ utility::icon icon; - /** Guild splash */ + /** + * @brief Guild splash + */ utility::icon splash; - /** Guild discovery splash */ + /** + * @brief Guild discovery splash + */ utility::icon discovery_splash; - /** Server banner */ + /** + * @brief Server banner + */ utility::icon banner; - /** Snowflake id of guild owner */ + /** + * @brief Snowflake id of guild owner + */ snowflake owner_id; - /** Snowflake ID of AFK voice channel or 0 */ + /** + * @brief Snowflake ID of AFK voice channel or 0 + */ snowflake afk_channel_id; - /** ID of creating application, if any, or 0 */ + /** + * @brief ID of creating application, if any, or 0 + */ snowflake application_id; - /** ID of system channel where discord update messages are sent */ + /** + * @brief ID of system channel where discord update messages are sent + */ snowflake system_channel_id; - /** ID of rules channel for communities */ + /** + * @brief ID of rules channel for communities + */ snowflake rules_channel_id; - /** Public updates channel id or 0 */ + /** + * @brief Public updates channel id or 0 + */ snowflake public_updates_channel_id; - /** Snowflake ID of widget channel, or 0 */ + /** + * @brief Snowflake ID of widget channel, or 0 + */ snowflake widget_channel_id; - /** The id of the channel where admins and moderators of Community guilds receive safety alerts from Discord */ + /** + * @brief The id of the channel where admins and moderators of Community guilds receive safety alerts from Discord + */ snowflake safety_alerts_channel_id; - /** Approximate member count. May be sent as zero */ + /** + * @brief Approximate member count. May be sent as zero + */ uint32_t member_count; - /** Flags bitmask as defined by values within dpp::guild_flags */ + /** + * @brief Flags bitmask as defined by values within dpp::guild_flags + */ uint32_t flags; /** @@ -771,31 +1143,49 @@ class DPP_EXPORT guild : public managed, public json_interface { */ uint16_t flags_extra; - /** Shard ID of the guild */ + /** + * @brief Shard ID of the guild + */ uint16_t shard_id; - /** Number of boosters */ + /** + * @brief Number of boosters + */ uint16_t premium_subscription_count; - /** Voice AFK timeout before moving users to AFK channel */ + /** + * @brief Voice AFK timeout before moving users to AFK channel + */ guild_afk_timeout_t afk_timeout; - /** Maximum users in a video channel, or 0 */ + /** + * @brief Maximum users in a video channel, or 0 + */ uint8_t max_video_channel_users; - /** Setting for how notifications are to be delivered to users */ + /** + * @brief Setting for how notifications are to be delivered to users + */ default_message_notification_t default_message_notifications; - /** Boost level */ + /** + * @brief Boost level + */ guild_premium_tier_t premium_tier; - /** Verification level of server */ + /** + * @brief Verification level of server + */ verification_level_t verification_level; - /** Whether or not explicit content filtering is enable and what setting it is */ + /** + * @brief Whether or not explicit content filtering is enable and what setting it is + */ guild_explicit_content_t explicit_content_filter; - /** If multi factor authentication is required for moderators or not */ + /** + * @brief If multi factor authentication is required for moderators or not + */ mfa_level_t mfa_level; /** @@ -1262,7 +1652,9 @@ class DPP_EXPORT guild : public managed, public json_interface { bool has_invites_disabled() const; }; -/** A container of guilds */ +/** + * @brief A container of guilds + */ typedef std::unordered_map guild_map; /** @@ -1308,32 +1700,58 @@ class DPP_EXPORT guild_widget : public json_interface { /** * @brief The onboarding mode for the dpp::onboarding object. Defines the criteria used to satisfy Onboarding constraints that are required for enabling. */ -enum onboarding_mode: uint8_t { - gom_default = 0, //!< Counts only Default Channels towards constraints - gom_advanced = 1, //!< Counts Default Channels and Questions towards constraints +enum onboarding_mode : uint8_t { + /** + * @brief Counts only Default Channels towards constraints. + */ + gom_default = 0, + + /** + * @brief Counts Default Channels and Questions towards constraints. + */ + gom_advanced = 1, }; /** * @brief The various types of dpp::onboarding_prompt */ -enum onboarding_prompt_type: uint8_t { - opt_multiple_choice = 0, //!< Multiple choice - opt_dropdown = 1, //!< Dropdown +enum onboarding_prompt_type : uint8_t { + /** + * @brief Multiple choice. + */ + opt_multiple_choice = 0, + + /** + * @brief Dropdown. + */ + opt_dropdown = 1, }; /** * @brief Various flags for dpp::onboarding_prompt */ -enum onboarding_prompt_flags: uint8_t { - opf_single_select = 1 << 0, //!< Indicates whether users are limited to selecting one option for the prompt - opf_required = 1 << 1, //!< Indicates whether the prompt is required before a user completes the onboarding flow - opf_in_onboarding = 1 << 2, //!< Indicates whether the prompt is present in the onboarding flow. If set, the prompt will only appear in the Channels & Roles tab +enum onboarding_prompt_flags : uint8_t { + /** + * @brief Indicates whether users are limited to selecting one option for the prompt. + */ + opf_single_select = 1 << 0, + + /** + * @brief Indicates whether the prompt is required before a user completes the onboarding flow. + */ + opf_required = 1 << 1, + + /** + * @brief Indicates whether the prompt is present in the onboarding flow. + * If set, the prompt will only appear in the Channels & Roles tab + */ + opf_in_onboarding = 1 << 2, }; /** * @brief Represents an onboarding prompt option */ -struct DPP_EXPORT onboarding_prompt_option: public managed, public json_interface { +struct DPP_EXPORT onboarding_prompt_option : public managed, public json_interface { protected: friend struct json_interface; @@ -1354,11 +1772,30 @@ struct DPP_EXPORT onboarding_prompt_option: public managed, public json_interfac json to_json_impl(bool with_id = false) const; public: - std::vector channel_ids; //!< IDs for channels a member is added to when the option is selected - std::vector role_ids; //!< IDs for roles assigned to a member when the option is selected - dpp::emoji emoji; //!< Emoji of the option - std::string title; //!< Title of the option - std::string description; //!< Description of the option + /** + * @brief IDs for channels a member is added to when the option is selected. + */ + std::vector channel_ids; + + /** + * @brief IDs for roles assigned to a member when the option is selected + */ + std::vector role_ids; + + /** + * @brief Emoji of the option + */ + dpp::emoji emoji; + + /** + * @brief Title of the option + */ + std::string title; + + /** + * @brief Description of the option + */ + std::string description; /** * @brief Construct a new onboarding prompt option object @@ -1398,7 +1835,7 @@ struct DPP_EXPORT onboarding_prompt_option: public managed, public json_interfac /** * @brief Represents an onboarding prompt */ -struct DPP_EXPORT onboarding_prompt: public managed, public json_interface { +struct DPP_EXPORT onboarding_prompt : public managed, public json_interface { protected: friend struct json_interface; @@ -1419,10 +1856,25 @@ struct DPP_EXPORT onboarding_prompt: public managed, public json_interface options; //!< Options available within the prompt - std::string title; //!< Title of the prompt - uint8_t flags; //!< A set of flags built from the bitmask defined by dpp::onboarding_prompt_flags + /** + * @brief Type of prompt (defaults to dpp::opt_multiple_choice). + */ + onboarding_prompt_type type; + + /** + * @brief Options available within the prompt + */ + std::vector options; + + /** + * @brief Title of the prompt. + */ + std::string title; + + /** + * @brief A set of flags built from the bitmask defined by dpp::onboarding_prompt_flags + */ + uint8_t flags; /** * @brief Construct a new onboarding prompt object @@ -1472,7 +1924,7 @@ struct DPP_EXPORT onboarding_prompt: public managed, public json_interface { +struct DPP_EXPORT onboarding : public json_interface { protected: friend struct json_interface; @@ -1493,11 +1945,30 @@ struct DPP_EXPORT onboarding: public json_interface { json to_json_impl(bool with_id = false) const; public: - snowflake guild_id; //!< ID of the guild this onboarding is part of - std::vector prompts; //!< Prompts shown during onboarding and in customize community - std::vector default_channel_ids; //!< Channel IDs that members get opted into automatically - onboarding_mode mode; //!< Current mode of onboarding (defaults to dpp::gom_default) - bool enabled; //!< Whether onboarding is enabled in the guild + /** + * @brief ID of the guild this onboarding is part of. + */ + snowflake guild_id; + + /** + * @brief Prompts shown during onboarding and in customize community. + */ + std::vector prompts; + + /** + * @brief Channel IDs that members get opted into automatically + */ + std::vector default_channel_ids; + + /** + * @brief Current mode of onboarding (defaults to dpp::gom_default) + */ + onboarding_mode mode; + + /** + * @brief Whether onboarding is enabled in the guild + */ + bool enabled; /** * @brief Construct a new onboarding object @@ -1544,7 +2015,9 @@ struct DPP_EXPORT onboarding: public json_interface { */ void from_json(const nlohmann::json& j, guild_member& gm); -/** A container of guild members */ +/** + * @brief A container of guild members + */ typedef std::unordered_map guild_member_map; /** diff --git a/include/dpp/httpsclient.h b/include/dpp/httpsclient.h index d9ca9e582a..f043d533f7 100644 --- a/include/dpp/httpsclient.h +++ b/include/dpp/httpsclient.h @@ -96,6 +96,7 @@ struct multipart_content { * @brief Multipart body */ std::string body; + /** * @brief MIME type */ @@ -111,14 +112,17 @@ struct http_connect_info { * @brief True if the connection should be SSL */ bool is_ssl; + /** * @brief The request scheme, e.g. 'https' or 'http' */ std::string scheme; + /** * @brief The request hostname part, e.g. 'discord.com' */ std::string hostname; + /** * @brief The port number, either determined from the scheme, * or from the part of the hostname after a colon ":" character @@ -130,8 +134,7 @@ struct http_connect_info { * @brief Implements a HTTPS socket client based on the SSL client. * @note plaintext HTTP without SSL is also supported via a "downgrade" setting */ -class DPP_EXPORT https_client : public ssl_client -{ +class DPP_EXPORT https_client : public ssl_client { /** * @brief Current connection state */ @@ -215,7 +218,6 @@ class DPP_EXPORT https_client : public ssl_client bool do_buffer(std::string& buffer); protected: - /** * @brief Start the connection */ @@ -228,7 +230,6 @@ class DPP_EXPORT https_client : public ssl_client http_state get_state(); public: - /** * @brief Connect to a specific HTTP(S) server and complete a request. * diff --git a/include/dpp/integration.h b/include/dpp/integration.h index 98d5cb507d..1e48c7be65 100644 --- a/include/dpp/integration.h +++ b/include/dpp/integration.h @@ -34,13 +34,24 @@ namespace dpp { * @brief Integration types */ enum integration_type { - /// Twitch integration + /** + * @brief Twitch integration + */ i_twitch, - /// YouTube integration + + /** + * @brief YouTube integration + */ i_youtube, - /// Discord integration + + /** + * @brief Discord integration + */ i_discord, - /// Subscription + + /** + * @brief Subscription + */ i_guild_subscription, }; @@ -48,30 +59,79 @@ enum integration_type { * @brief Integration flags */ enum integration_flags { - if_enabled = 0b00000001, //!< is this integration enabled - if_syncing = 0b00000010, //!< is this integration syncing @warning This is not provided for discord bot integrations. - if_emoticons = 0b00000100, //!< whether emoticons should be synced for this integration (twitch only currently) @warning This is not provided for discord bot integrations. - if_revoked = 0b00001000, //!< has this integration been revoked @warning This is not provided for discord bot integrations. - if_expire_kick = 0b00010000, //!< kick user when their subscription expires, otherwise only remove the role that is specified by `role_id`. @warning This is not provided for discord bot integrations. + /** + * @brief Is this integration enabled? + */ + if_enabled = 0b00000001, + + /** + * @brief Is this integration syncing? + * @warning This is not provided for discord bot integrations. + */ + if_syncing = 0b00000010, + + /** + * @brief Whether emoticons should be synced for this integration (twitch only currently). + * @warning This is not provided for discord bot integrations. + */ + if_emoticons = 0b00000100, + + /** + * @brief Has this integration been revoked? + * @warning This is not provided for discord bot integrations. + */ + if_revoked = 0b00001000, + + /** + * @brief Kick user when their subscription expires, otherwise only remove the role that is specified by `role_id`. + * @warning This is not provided for discord bot integrations. + */ + if_expire_kick = 0b00010000, }; /** * @brief An application that has been integrated */ struct DPP_EXPORT integration_app { - snowflake id; //!< the id of the app - std::string name; //!< the name of the app - utility::iconhash icon; //!< the icon hash of the app - std::string description; //!< the description of the app - class user* bot; //!< the bot associated with this application + /** + * @brief The id of the app. + */ + snowflake id; + + /** + * @brief The name of the app. + */ + std::string name; + + /** + * @brief The icon hash of the app. + */ + utility::iconhash icon; + + /** + * @brief The description of the app + */ + std::string description; + + /** + * @brief The bot associated with this application. + */ + class user* bot; }; /** * @brief The account information for an integration. */ struct DPP_EXPORT integration_account { - snowflake id; //!< id of the account - std::string name; //!< name of the account + /** + * @brief ID of the account + */ + snowflake id; + + /** + * @brief Name of the account. + */ + std::string name; }; /** @@ -94,17 +154,68 @@ class DPP_EXPORT integration : public managed, public json_interface scopes; //!< the scopes the application has been authorized for + /** + * @brief Integration name. + */ + std::string name; + + /** + * @brief Integration type (twitch, youtube, discord, or guild_subscription). + */ + integration_type type; + + /** + * @brief Integration flags from dpp::integration_flags + */ + uint8_t flags; + + /** + * @brief ID that this integration uses for "subscribers". + * + * @warning This is not provided for discord bot integrations. + */ + snowflake role_id; + + /** + * @brief The grace period (in days) before expiring subscribers. + * + * @warning This is not provided for discord bot integrations. + */ + uint32_t expire_grace_period; + + /** + * @brief User for this integration + */ + user user_obj; + + /** + * @brief Integration account information + */ + integration_account account; + + /** + * @brief When this integration was last synced. + * + * @warning This is not provided for discord bot integrations. + */ + time_t synced_at; + + /** + * @brief How many subscribers this integration has. + * + * @warning This is not provided for discord bot integrations. + */ + uint32_t subscriber_count; + + /** + * @brief The bot/OAuth2 application for discord integrations. + */ + integration_app app; + + /** + * @brief The scopes the application has been authorized for. + */ + std::vector scopes; /** Default constructor */ integration(); @@ -158,16 +269,55 @@ class DPP_EXPORT connection : public json_interface { connection& fill_from_json_impl(nlohmann::json* j); public: - std::string id; //!< id of the connection account - std::string name; //!< the username of the connection account - std::string type; //!< the service of the connection (twitch, youtube, discord, or guild_subscription) - bool revoked; //!< Optional: whether the connection is revoked - std::vector integrations; //!< Optional: an array of partial server integrations - bool verified; //!< whether the connection is verified - bool friend_sync; //!< whether friend sync is enabled for this connection - bool show_activity; //!< whether activities related to this connection will be shown in presence updates - bool two_way_link; //!< Whether this connection has a corresponding third party OAuth2 token - bool visible; //!< visibility of this connection + /** + * @brief ID of the connection account. + */ + std::string id; + + /** + * @brief the username of the connection account. + */ + std::string name; + + /** + * @brief the service of the connection (twitch, youtube, discord, or guild_subscription). + */ + std::string type; + + /** + * @brief Optional: whether the connection is revoked. + */ + bool revoked; + + /** + * @brief Optional: an array of partial server integrations. + */ + std::vector integrations; + + /** + * @brief Whether the connection is verified. + */ + bool verified; + + /** + * @brief Whether friend sync is enabled for this connection. + */ + bool friend_sync; + + /** + * @brief Whether activities related to this connection will be shown in presence updates. + */ + bool show_activity; + + /** + * @brief Whether this connection has a corresponding third party OAuth2 token. + */ + bool two_way_link; + + /** + * @brief Visibility of this connection. + */ + bool visible; /** * @brief Construct a new connection object @@ -175,10 +325,14 @@ class DPP_EXPORT connection : public json_interface { connection(); }; -/** A group of integrations */ +/** + * @brief A group of integrations + */ typedef std::unordered_map integration_map; -/** A group of connections */ +/** + * @brief A group of connections + */ typedef std::unordered_map connection_map; } // namespace dpp diff --git a/include/dpp/intents.h b/include/dpp/intents.h index 80bc94bba2..d225a9d5e1 100644 --- a/include/dpp/intents.h +++ b/include/dpp/intents.h @@ -31,56 +31,124 @@ namespace dpp { * your real life ID. */ enum intents { - /// Intent for receipt of guild information + /** + * @brief Intent for receipt of guild information. + */ i_guilds = (1 << 0), - /// Intent for receipt of guild members + + /** + * @brief Intent for receipt of guild members. + */ i_guild_members = (1 << 1), - /// Intent for receipt of guild bans + + /** + * @brief Intent for receipt of guild bans. + */ i_guild_bans = (1 << 2), - /// Intent for receipt of guild emojis + + /** + * @brief Intent for receipt of guild emojis. + */ i_guild_emojis = (1 << 3), - /// Intent for receipt of guild integrations + + /** + * @brief Intent for receipt of guild integrations. + */ i_guild_integrations = (1 << 4), - /// Intent for receipt of guild webhooks + + /** + * @brief Intent for receipt of guild webhooks. + */ i_guild_webhooks = (1 << 5), - /// Intent for receipt of guild invites + + /** + * @brief Intent for receipt of guild invites. + */ i_guild_invites = (1 << 6), - /// Intent for receipt of guild voice states + + /** + * @brief Intent for receipt of guild voice states. + */ i_guild_voice_states = (1 << 7), - /// Intent for receipt of guild presences + + /** + * @brief Intent for receipt of guild presences. + */ i_guild_presences = (1 << 8), - /// Intent for receipt of guild messages + + /** + * @brief Intent for receipt of guild messages. + */ i_guild_messages = (1 << 9), - /// Intent for receipt of guild message reactions + + /** + * @brief Intent for receipt of guild message reactions. + */ i_guild_message_reactions = (1 << 10), - /// Intent for receipt of guild message typing notifications + + /** + * @brief Intent for receipt of guild message typing notifications. + */ i_guild_message_typing = (1 << 11), - /// Intent for receipt of direct messages (DMs) + + /** + * @brief Intent for receipt of direct messages (DMs). + */ i_direct_messages = (1 << 12), - /// Intent for receipt of direct message reactions + + /** + * @brief Intent for receipt of direct message reactions. + */ i_direct_message_reactions = (1 << 13), - /// Intent for receipt of direct message typing notifications + + /** + * @brief Intent for receipt of direct message typing notifications. + */ i_direct_message_typing = (1 << 14), - /// Intent for receipt of message content + + /** + * @brief Intent for receipt of message content. + */ i_message_content = (1 << 15), - /// Scheduled events + + /** + * @brief Scheduled events. + */ i_guild_scheduled_events = (1 << 16), - /// Auto moderation configuration + + /** + * @brief Auto moderation configuration. + */ i_auto_moderation_configuration = (1 << 20), - /// Auto moderation configuration + + /** + * @brief Auto moderation configuration. + */ i_auto_moderation_execution = (1 << 21), - /// Default D++ intents (all non-privileged intents) + + /** + * @brief Default D++ intents (all non-privileged intents). + */ i_default_intents = dpp::i_guilds | dpp::i_guild_bans | dpp::i_guild_emojis | dpp::i_guild_integrations | dpp::i_guild_webhooks | dpp::i_guild_invites | dpp::i_guild_voice_states | dpp::i_guild_messages | dpp::i_guild_message_reactions | dpp::i_guild_message_typing | dpp::i_direct_messages | dpp::i_direct_message_typing | dpp::i_direct_message_reactions | dpp::i_guild_scheduled_events | dpp::i_auto_moderation_configuration | - dpp::i_auto_moderation_execution, - /// Privileged intents requiring ID + dpp::i_auto_moderation_execution, + + /** + * @brief Privileged intents requiring ID. + */ i_privileged_intents = dpp::i_guild_members | dpp::i_guild_presences | dpp::i_message_content, - /// Every single intent + + /** + * @brief Every single intent (dpp::i_default_intents and dpp::i_privileged_intents). + */ i_all_intents = dpp::i_default_intents | dpp::i_privileged_intents, - /// Unverified bots default intents + + /** + * @brief Unverified bots default intents. + */ i_unverified_default_intents = dpp::i_default_intents | dpp::i_message_content }; diff --git a/include/dpp/invite.h b/include/dpp/invite.h index 37798ec410..c20708056a 100644 --- a/include/dpp/invite.h +++ b/include/dpp/invite.h @@ -36,9 +36,20 @@ namespace dpp { * @brief Invite target types for dpp::invite */ enum invite_target_t : uint8_t { - itt_none = 0, //!< Undefined invite target type - itt_stream = 1, //!< Stream target type - itt_embedded_application = 2, //!< Embedded Application target type + /** + * @brief Undefined invite target type. + */ + itt_none = 0, + + /** + * @brief Stream target type. + */ + itt_stream = 1, + + /** + * @brief Embedded Application target type. + */ + itt_embedded_application = 2, }; /** @@ -61,74 +72,119 @@ class DPP_EXPORT invite : public json_interface { virtual json to_json_impl(bool with_id = false) const; public: - /** Invite code + /** + * @brief Invite code. */ std::string code; - /** Readonly expiration timestamp of this invite or 0 if the invite doesn't expire + + /** + * @brief Readonly expiration timestamp of this invite or 0 if the invite doesn't expire. * @note Only returned from cluster::invite_get */ time_t expires_at; - /** Guild ID this invite is for + + /** + * @brief Guild ID this invite is for. */ snowflake guild_id; - /** The partial guild this invite is for. Only filled in retrieved invites + + /** + * @brief The partial guild this invite is for. + * @note Only filled in retrieved invites. */ guild destination_guild; - /** Channel ID this invite is for + + /** + * @brief Channel ID this invite is for. */ snowflake channel_id; - /** The partial channel this invite is for. Only filled in retrieved invites + + /** + * @brief The partial channel this invite is for. + * @note Only filled in retrieved invites. */ channel destination_channel; - /** User ID who created this invite + + /** + * @brief User ID who created this invite. * @deprecated Use the `inviter` field instead */ snowflake inviter_id; - /** User who created this invite + + /** + * @brief User who created this invite. */ user inviter; - /** The user ID whose stream to display for this voice channel stream invite + + /** + * @brief The user ID whose stream to display for this voice channel stream invite. */ snowflake target_user_id; - /** Target type for this voice channel invite + + /** + * @brief Target type for this voice channel invite. */ invite_target_t target_type; - /** Approximate number of online users + + /** + * @brief Approximate number of online users. * @note Only returned from cluster::invite_get */ uint32_t approximate_presence_count; - /** Approximate number of total users online and offline - * @note Only returned from cluster::invite_get + + /** + * @brief Approximate number of total users online and offline. + * @note Only returned from cluster::invite_get. */ uint32_t approximate_member_count; - /** Duration (in seconds) after which the invite expires, or 0 for no expiration. Must be between 0 and 604800 (7 days). Defaults to 86400 (1 day) + + /** + * @brief Duration (in seconds) after which the invite expires, or 0 for no expiration. Defaults to 86400 (1 day). + * + * @note Must be between 0 and 604800 (7 days). */ uint32_t max_age; - /** Maximum number of uses, or 0 for unlimited. Must be between 0 and 100. Defaults to 0 + + /** + * @brief Maximum number of uses, or 0 for unlimited. Defaults to 0. + * + * @note Must be between 0 and 100. */ uint8_t max_uses; - /** Whether this invite only grants temporary membership + + /** + * @brief Whether this invite only grants temporary membership. */ bool temporary; - /** True if this invite should not replace or "attach to" similar invites + + /** + * @brief True if this invite should not replace or "attach to" similar invites. */ bool unique; - /** How many times this invite has been used + + /** + * @brief How many times this invite has been used. */ uint32_t uses; - /** The stage instance data if there is a public stage instance in the stage channel this invite is for + + /** + * @note The stage instance data if there is a public stage instance in the stage channel this invite is for. * @deprecated Deprecated */ stage_instance stage; - /** Timestamp at which the invite was created + + /** + * @brief Timestamp at which the invite was created. */ time_t created_at; - /** Constructor + /** + * @brief Constructor. */ invite(); - /** Destructor + /** + * @brief Destructor. */ virtual ~invite() = default; @@ -181,7 +237,9 @@ class DPP_EXPORT invite : public json_interface { invite& set_unique(const bool is_unique); }; -/** A container of invites */ +/** + * @brief A container of invites + */ typedef std::unordered_map invite_map; } // namespace dpp diff --git a/include/dpp/json_interface.h b/include/dpp/json_interface.h index a5c5fbd3e5..5c3fb69c36 100644 --- a/include/dpp/json_interface.h +++ b/include/dpp/json_interface.h @@ -24,48 +24,50 @@ #include namespace dpp { + +/** + * @brief Represents an interface for an object that can optionally implement functions + * for converting to and from nlohmann::json. The methods are only present if the actual object + * also has those methods. + * + * @tparam T Type of class that implements the interface + */ +template +struct DPP_EXPORT json_interface { /** - * @brief Represents an interface for an object that can optionally implement functions - * for converting to and from nlohmann::json. The methods are only present if the actual object - * also has those methods. + * @brief Convert object from nlohmann::json * - * @tparam T Type of class that implements the interface + * @param j nlohmann::json object + * @return T& Reference to self for fluent calling */ - template - struct DPP_EXPORT json_interface { - /** - * @brief Convert object from nlohmann::json - * - * @param j nlohmann::json object - * @return T& Reference to self for fluent calling - */ - template ().fill_from_json_impl(std::declval()))> - T& fill_from_json(nlohmann::json* j) { - return static_cast(this)->fill_from_json_impl(j); - } + template ().fill_from_json_impl(std::declval()))> + T& fill_from_json(nlohmann::json* j) { + return static_cast(this)->fill_from_json_impl(j); + } - /** - * @brief Convert object to nlohmann::json - * - * @param with_id Whether to include the ID or not - * @note Some fields are conditionally filled, do not rely on all fields being present - * @return json Json built from the structure - */ - template ().to_json_impl(bool{}))> - auto to_json(bool with_id = false) const { - return static_cast(this)->to_json_impl(with_id); - } + /** + * @brief Convert object to nlohmann::json + * + * @param with_id Whether to include the ID or not + * @note Some fields are conditionally filled, do not rely on all fields being present + * @return json Json built from the structure + */ + template ().to_json_impl(bool{}))> + auto to_json(bool with_id = false) const { + return static_cast(this)->to_json_impl(with_id); + } + + /** + * @brief Convert object to json string + * + * @param with_id Whether to include the ID or not + * @note Some fields are conditionally filled, do not rely on all fields being present + * @return std::string Json built from the structure + */ + template ().to_json_impl(bool{}))> + std::string build_json(bool with_id = false) const { + return to_json(with_id).dump(); + } +}; - /** - * @brief Convert object to json string - * - * @param with_id Whether to include the ID or not - * @note Some fields are conditionally filled, do not rely on all fields being present - * @return std::string Json built from the structure - */ - template ().to_json_impl(bool{}))> - std::string build_json(bool with_id = false) const { - return to_json(with_id).dump(); - } - }; } // namespace dpp diff --git a/include/dpp/managed.h b/include/dpp/managed.h index 86188f7da8..4ccd2e5318 100644 --- a/include/dpp/managed.h +++ b/include/dpp/managed.h @@ -26,91 +26,91 @@ namespace dpp { - /** @brief The managed class is the base class for various types that can - * be stored in a cache that are identified by a dpp::snowflake id. +/** @brief The managed class is the base class for various types that can + * be stored in a cache that are identified by a dpp::snowflake id. + */ +class DPP_EXPORT managed { +public: + /** + * @brief 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. */ - class DPP_EXPORT managed { - public: - /** - * @brief 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 id = {}; + snowflake id = {}; - /** - * @brief Constructor, initialises id to 0. - */ - managed() = default; + /** + * @brief Constructor, initialises id to 0. + */ + managed() = default; - /** - * @brief Constructor, initialises ID - * @param nid ID to set - */ - managed(const snowflake nid) : id{nid} {} + /** + * @brief Constructor, initialises ID + * @param nid ID to set + */ + managed(const snowflake nid) : id{nid} {} - /** - * @brief Copy constructor - * @param rhs Object to copy - */ - managed(const managed &rhs) = default; + /** + * @brief Copy constructor + * @param rhs Object to copy + */ + managed(const managed &rhs) = default; - /** - * @brief Move constructor - * - * Effectively equivalent to copy constructor - * @param rhs Object to move from - */ - managed(managed &&rhs) = default; + /** + * @brief Move constructor + * + * Effectively equivalent to copy constructor + * @param rhs Object to move from + */ + managed(managed &&rhs) = default; - /** - * @brief Destroy the managed object - */ - virtual ~managed() = default; + /** + * @brief Destroy the managed object + */ + virtual ~managed() = default; - /** - * @brief Copy assignment operator - * @param rhs Object to copy - */ - managed &operator=(const managed& rhs) = default; + /** + * @brief Copy assignment operator + * @param rhs Object to copy + */ + managed &operator=(const managed& rhs) = default; - /** - * @brief Move assignment operator - * @param rhs Object to move from - */ - managed &operator=(managed&& rhs) = default; + /** + * @brief Move assignment operator + * @param rhs Object to move from + */ + managed &operator=(managed&& rhs) = default; - /** - * @brief Get the creation time of this object according to Discord. - * - * @return double creation time inferred from the snowflake ID. - * The minimum possible value is the first second of 2015. - */ - constexpr double get_creation_time() const noexcept { - return id.get_creation_time(); - }; + /** + * @brief Get the creation time of this object according to Discord. + * + * @return double creation time inferred from the snowflake ID. + * The minimum possible value is the first second of 2015. + */ + constexpr double get_creation_time() const noexcept { + return id.get_creation_time(); + }; - /** - * @brief Comparison operator for comparing two managed objects by id - * - * @param other Other object to compare against - * @return true objects are the same id - * @return false objects are not the same id - */ - constexpr bool operator==(const managed& other) const noexcept { - return id == other.id; - } + /** + * @brief Comparison operator for comparing two managed objects by id + * + * @param other Other object to compare against + * @return true objects are the same id + * @return false objects are not the same id + */ + constexpr bool operator==(const managed& other) const noexcept { + return id == other.id; + } - /** - * @brief Comparison operator for comparing two managed objects by id - * - * @param other Other object to compare against - * @return true objects are not the same id - * @return false objects are the same id - */ - constexpr bool operator!=(const managed& other) const noexcept { - return id != other.id; - } - }; + /** + * @brief Comparison operator for comparing two managed objects by id + * + * @param other Other object to compare against + * @return true objects are not the same id + * @return false objects are the same id + */ + constexpr bool operator!=(const managed& other) const noexcept { + return id != other.id; + } +}; } // namespace dpp