From 908588c7a87a58aadf4a6519df7c725ce539bcd4 Mon Sep 17 00:00:00 2001 From: Arshia Aghaei Date: Sat, 30 Mar 2024 13:01:16 +0330 Subject: [PATCH] feat: Added is_guild_owner for dpp::guild_member (#1109) Co-authored-by: Craig Edwards (Brain) --- include/dpp/guild.h | 8 ++++++++ src/dpp/guild.cpp | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/include/dpp/guild.h b/include/dpp/guild.h index db631c33d1..28c9bf720a 100644 --- a/include/dpp/guild.h +++ b/include/dpp/guild.h @@ -520,6 +520,14 @@ class DPP_EXPORT guild_member : public json_interface { */ 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 * diff --git a/src/dpp/guild.cpp b/src/dpp/guild.cpp index a1162321ea..236e05869d 100644 --- a/src/dpp/guild.cpp +++ b/src/dpp/guild.cpp @@ -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; }