Skip to content

Commit

Permalink
feat: add premium_progress_bar_enabled, fixes #270
Browse files Browse the repository at this point in the history
  • Loading branch information
braindigitalis committed Mar 27, 2022
1 parent 1cacd28 commit a333335
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
35 changes: 27 additions & 8 deletions include/dpp/guild.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ enum guild_flags : uint32_t {
g_channel_banners = 0b10000000000000000000000000000000,
};

/**
* @brief Additional boolean flag values for guild, as guild_flags is full
*/
enum guild_flags_extra : uint8_t {
/** Guild has premium progress bar enabled */
g_premium_progress_bar_enabled = 0b00000001,
};

/**
* @brief Various flags that can be used to indicate the status of a guild member
*/
Expand Down Expand Up @@ -491,6 +499,11 @@ class DPP_EXPORT guild : public managed, public json_interface<guild> {
*/
guild_nsfw_level_t nsfw_level;

/**
* @brief Additional flags
*/
uint8_t flags_extra;

/** Default constructor, zeroes all values */
guild();

Expand Down Expand Up @@ -554,37 +567,37 @@ class DPP_EXPORT guild : public managed, public json_interface<guild> {
*/
bool connect_member_voice(snowflake user_id, bool self_mute = false, bool self_deaf = false);

/**
/**
* @brief Get the banner url of the guild if it have one, otherwise returns an empty string
*
* @param size The size of the banner in pixels. It can be any power of two between 16 and 4096. if not specified, the default sized banner is returned.
* @return std::string banner url or empty string
*/
std::string get_banner_url(uint16_t size = 0) const;
std::string get_banner_url(uint16_t size = 0) const;

/**
/**
* @brief Get the discovery splash url of the guild if it have one, otherwise returns an empty string
*
* @param size The size of the discovery splash in pixels. It can be any power of two between 16 and 4096. if not specified, the default sized discovery splash is returned.
* @return std::string discovery splash url or empty string
*/
std::string get_discovery_splash_url(uint16_t size = 0) const;
std::string get_discovery_splash_url(uint16_t size = 0) const;

/**
/**
* @brief Get the icon url of the guild if it have one, otherwise returns an empty string
*
* @param size The size of the icon in pixels. It can be any power of two between 16 and 4096. if not specified, the default sized icon is returned.
* @return std::string icon url or empty string
*/
std::string get_icon_url(uint16_t size = 0) const;
std::string get_icon_url(uint16_t size = 0) const;

/**
/**
* @brief Get the splash url of the guild if it have one, otherwise returns an empty string
*
* @param size The size of the splash in pixels. It can be any power of two between 16 and 4096. if not specified, the default sized splash is returned.
* @return std::string splash url or empty string
*/
std::string get_splash_url(uint16_t size = 0) const;
std::string get_splash_url(uint16_t size = 0) const;

/**
* @brief Set the name of the guild in the object
Expand Down Expand Up @@ -763,6 +776,12 @@ class DPP_EXPORT guild : public managed, public json_interface<guild> {
* @return bool has channel banners
*/
bool has_channel_banners() const;

/**
* @brief True if the premium progress bar is enabled
* @return bool has progress bar enabled
*/
bool has_premium_progress_bar_enabled() const;
};

/** A container of guilds */
Expand Down
10 changes: 9 additions & 1 deletion src/dpp/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ guild::guild() :
verification_level(ver_none),
explicit_content_filter(expl_disabled),
mfa_level(mfa_none),
nsfw_level(nsfw_default)
nsfw_level(nsfw_default),
flags_extra(0)
{
}

Expand Down Expand Up @@ -247,6 +248,10 @@ bool guild::has_vanity_url() const {
return this->flags & g_vanity_url;
}

bool guild::has_premium_progress_bar_enabled() const {
return this->flags_extra & g_premium_progress_bar_enabled;
}

bool guild::has_channel_banners() const {
return this->flags & g_channel_banners;
}
Expand Down Expand Up @@ -359,6 +364,7 @@ std::string guild::build_json(bool with_id) const {
if (system_channel_id) {
j["system_channel_id"] = system_channel_id;
}
j["premium_progress_bar_enabled"] = (bool)(flags_extra & g_premium_progress_bar_enabled);
if (rules_channel_id) {
j["rules_channel_id"] = rules_channel_id;
}
Expand Down Expand Up @@ -418,6 +424,8 @@ guild& guild::fill_from_json(discord_client* shard, nlohmann::json* d) {
this->flags |= bool_not_null(d, "large") ? dpp::g_large : 0;
this->flags |= bool_not_null(d, "widget_enabled") ? dpp::g_widget_enabled : 0;

this->flags_extra |= bool_not_null(d, "premium_progress_bar_enabled") ? dpp::g_premium_progress_bar_enabled : 0;

for (auto & feature : (*d)["features"]) {
auto f = featuremap.find(feature.get<std::string>());
if (f != featuremap.end()) {
Expand Down

0 comments on commit a333335

Please sign in to comment.