Skip to content

Commit f51f305

Browse files
feat: application team member roles feature (#805)
1 parent c060165 commit f51f305

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

include/dpp/application.h

+14
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ struct DPP_EXPORT application_install_params {
7676
std::vector<std::string> scopes; //!< The [scopes](https://discord.com/developers/docs/topics/oauth2#shared-resources-oauth2-scopes) as strings to add the application to the server with
7777
};
7878

79+
/**
80+
* @brief Team member role types for application team members.
81+
*
82+
* These are hard coded to string forms by discord. If further types are added,
83+
* this enum will be extended to support them.
84+
*/
85+
enum team_member_role_t : uint8_t {
86+
tmr_owner, //!< Team owner
87+
tmr_admin, //!< Team admin
88+
tmr_developer, //!< Developer
89+
tmr_readonly, //!< Read-Only
90+
};
91+
7992
/**
8093
* @brief Represents a team member on a team who maintain a bot/application
8194
*/
@@ -85,6 +98,7 @@ class DPP_EXPORT team_member {
8598
std::string permissions; //!< will always be [""]
8699
snowflake team_id; //!< the id of the parent team of which they are a member
87100
user member_user; //!< the avatar, discriminator, id, and username of the user
101+
team_member_role_t member_role; //!< the role of the user
88102
};
89103

90104
/**

src/dpp/application.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ application& application::fill_from_json(nlohmann::json* j) {
8484
for (auto m : t["members"]) {
8585
team_member tm;
8686
tm.membership_state = (team_member_status)int32_not_null(&m, "membership_state");
87+
std::string member_role = string_not_null(&m, "role");
88+
if (member_role == "owner") {
89+
tm.member_role = tmr_owner;
90+
} else if (member_role == "admin") {
91+
tm.member_role = tmr_admin;
92+
} else if (member_role == "developer") {
93+
tm.member_role = tmr_developer;
94+
} else {
95+
tm.member_role = tmr_readonly;
96+
}
8797
set_string_not_null(&m, "permissions", tm.permissions);
8898
set_snowflake_not_null(&m, "team_id", tm.team_id);
8999
tm.member_user = user().fill_from_json(&m["user"]);

0 commit comments

Comments
 (0)