Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added user flag for nitro basic #534

Merged
merged 2 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/dpp/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion include/dpp/user.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

/**
Expand Down Expand Up @@ -169,9 +171,16 @@ class DPP_EXPORT user : public managed, public json_interface<user> {
* @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
*
Expand Down
5 changes: 5 additions & 0 deletions src/dpp/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down