From 887fc13aee645d96e38cd83a80ae9741cf050661 Mon Sep 17 00:00:00 2001 From: Phil B Date: Sat, 29 Oct 2022 13:23:40 +0200 Subject: [PATCH] feat: added user flag for nitro basic --- include/dpp/channel.h | 2 +- include/dpp/user.h | 11 ++++++++++- src/dpp/user.cpp | 5 +++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/dpp/channel.h b/include/dpp/channel.h index d88d664f4d..5b37f33a94 100644 --- a/include/dpp/channel.h +++ b/include/dpp/channel.h @@ -52,7 +52,7 @@ enum channel_type : uint8_t { */ CHANNEL_STORE = 6, CHANNEL_ANNOUNCEMENT_THREAD = 10, //!< a temporary sub-channel within a GUILD_ANNOUNCEMENT channel - CHANNEL_PUBLIC_THREAD = 11, //!< a temporary sub-channel within a GUILD_TEXT channel + CHANNEL_PUBLIC_THREAD = 11, //!< a temporary sub-channel within a GUILD_TEXT or GUILD_FORUM channel CHANNEL_PRIVATE_THREAD = 12, //!< a temporary sub-channel within a GUILD_TEXT channel that is only viewable by those invited and those with the MANAGE_THREADS permission CHANNEL_STAGE = 13, //!< a "stage" channel, like a voice channel with one authorised speaker CHANNEL_DIRECTORY = 14, //!< the channel in a [hub](https://support.discord.com/hc/en-us/articles/4406046651927-Discord-Student-Hubs-FAQ) containing the listed servers diff --git a/include/dpp/user.h b/include/dpp/user.h index 14245e387c..36c10ba42e 100644 --- a/include/dpp/user.h +++ b/include/dpp/user.h @@ -74,6 +74,8 @@ enum user_flags : uint32_t { u_certified_moderator = 0b00010000000000000000000, /// User is a bot using HTTP interactions (shows online even when not connected to a websocket) u_bot_http_interactions = 0b00100000000000000000000, + /// User has nitro basic + u_nitro_basic = 0b01000000000000000000000, }; /** @@ -169,9 +171,16 @@ class DPP_EXPORT user : public managed, public json_interface { * @brief Return true if user has nitro classic. * This is mutually exclusive with nitro classic. * - * @return true if user has nitro classic + * @return true if user has nitro classic */ bool has_nitro_classic() const; + /** + * @brief Return true if user has nitro basic. + * This is mutually exclusive with nitro basic. + * + * @return true if user has nitro basic + */ + bool has_nitro_basic() const; /** * @brief Return true if user is a discord employee * diff --git a/src/dpp/user.cpp b/src/dpp/user.cpp index 6df81ff3bf..f1c2013db4 100644 --- a/src/dpp/user.cpp +++ b/src/dpp/user.cpp @@ -121,6 +121,10 @@ bool user::has_nitro_classic() const { return this->flags & u_nitro_classic; } +bool user::has_nitro_basic() const { + return this->flags & u_nitro_basic; +} + bool user::is_discord_employee() const { return this->flags & u_discord_employee; } @@ -239,6 +243,7 @@ void from_json(const nlohmann::json& j, user& u) { u.flags |= bool_not_null(&j, "verified") ? dpp::u_verified : 0; u.flags |= int8_not_null(&j, "premium_type") == 1 ? dpp::u_nitro_classic : 0; u.flags |= int8_not_null(&j, "premium_type") == 2 ? dpp::u_nitro_full : 0; + u.flags |= int8_not_null(&j, "premium_type") == 3 ? dpp::u_nitro_basic : 0; uint32_t flags = int32_not_null(&j, "flags"); flags |= int32_not_null(&j, "public_flags"); for (auto & flag : usermap) {