You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docpages/example_programs/misc/checking-member-permissions.md
+28
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,34 @@ if (c && c->get_user_permissions(member).can(dpp::p_send_messages)) {
15
15
}
16
16
```
17
17
18
+
### Role Hierarchy
19
+
20
+
The recommended and correct way to compare for roles in the hierarchy is using the comparison operators (`<`, `>`) on the \ref dpp::role::operator<(dpp::role, dpp::role) "dpp::role" objects themselves.
21
+
Keep in mind that multiple roles can have the same position number.
22
+
As a result, comparing roles by position alone can lead to subtle bugs when checking for role hierarchy.
23
+
24
+
For example let's say you have a ban command, and want to make sure that any issuer of the command can only ban members lower position than their own highest role.
Copy file name to clipboardexpand all lines: include/dpp/cluster.h
+4-4
Original file line number
Diff line number
Diff line change
@@ -2170,8 +2170,8 @@ class DPP_EXPORT cluster {
2170
2170
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
2171
2171
* @param c Channel to set permissions for
2172
2172
* @param overwrite_id Overwrite to change (a user or role ID)
2173
-
* @param allow allow permissions bitmask
2174
-
* @param deny deny permissions bitmask
2173
+
* @param allow Bitmask of allowed permissions (refer to enum dpp::permissions)
2174
+
* @param deny Bitmask of denied permissions (refer to enum dpp::permissions)
2175
2175
* @param member true if the overwrite_id is a user id, false if it is a channel id
2176
2176
* @param callback Function to call when the API call completes.
2177
2177
* On success the callback will contain a dpp::confirmation object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
@@ -2185,8 +2185,8 @@ class DPP_EXPORT cluster {
2185
2185
* @note This method supports audit log reasons set by the cluster::set_audit_reason() method.
2186
2186
* @param channel_id ID of the channel to set permissions for
2187
2187
* @param overwrite_id Overwrite to change (a user or role ID)
2188
-
* @param allow allow permissions bitmask
2189
-
* @param deny deny permissions bitmask
2188
+
* @param allow Bitmask of allowed permissions (refer to enum dpp::permissions)
2189
+
* @param deny Bitmask of denied permissions (refer to enum dpp::permissions)
2190
2190
* @param member true if the overwrite_id is a user id, false if it is a channel id
2191
2191
* @param callback Function to call when the API call completes.
2192
2192
* On success the callback will contain a dpp::confirmation object in confirmation_callback_t::value. On failure, the value is undefined and confirmation_callback_t::is_error() method will return true. You can obtain full error details with confirmation_callback_t::get_error().
0 commit comments