Skip to content

Commit

Permalink
feat: Added is_guild_owner for dpp::guild_member (#1109)
Browse files Browse the repository at this point in the history
Co-authored-by: Craig Edwards (Brain) <[email protected]>
  • Loading branch information
AA1999 and braindigitalis authored Mar 30, 2024
1 parent 68e7477 commit 908588c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/dpp/guild.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,14 @@ class DPP_EXPORT guild_member : public json_interface<guild_member> {
*/
bool has_rejoined() const;

/**
* @brief Is this user also the guild member?
* @return true if the user is the guild owner.
* @return false if the user is not the guild owner or the guild is not in the cache.
* @note If the guild cache is disabled, this function will always return false.
*/
bool is_guild_owner() const;

/**
* @brief Returns true if the user has completed onboarding
*
Expand Down
5 changes: 5 additions & 0 deletions src/dpp/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ bool guild_member::has_rejoined() const {
return flags & dpp::gm_did_rejoin;
}

bool guild_member::is_guild_owner() const {
auto* _guild = find_guild(guild_id);
return _guild != nullptr && _guild->owner_id == this->user_id;
}

bool guild_member::has_completed_onboarding() const {
return flags & dpp::gm_completed_onboarding;
}
Expand Down

0 comments on commit 908588c

Please sign in to comment.