Try making permissions to PermissionFlags
This commit is contained in:
parent
6c0d21867c
commit
97ca0c17eb
|
@ -16,8 +16,7 @@ pub struct RoleObject {
|
||||||
pub unicode_emoji: Option<String>,
|
pub unicode_emoji: Option<String>,
|
||||||
pub position: u16,
|
pub position: u16,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[serde(deserialize_with = "deserialize_string_from_number")]
|
pub permissions: PermissionFlags,
|
||||||
pub permissions: String,
|
|
||||||
pub managed: bool,
|
pub managed: bool,
|
||||||
pub mentionable: bool,
|
pub mentionable: bool,
|
||||||
#[cfg(feature = "sqlx")]
|
#[cfg(feature = "sqlx")]
|
||||||
|
@ -53,6 +52,7 @@ pub struct RoleTags {
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
|
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
|
||||||
pub struct PermissionFlags: u64 {
|
pub struct PermissionFlags: u64 {
|
||||||
const CREATE_INSTANT_INVITE = 1 << 0;
|
const CREATE_INSTANT_INVITE = 1 << 0;
|
||||||
const KICK_MEMBERS = 1 << 1;
|
const KICK_MEMBERS = 1 << 1;
|
||||||
|
@ -101,3 +101,9 @@ bitflags! {
|
||||||
const SEND_VOICE_MESSAGES = 1 << 46;
|
const SEND_VOICE_MESSAGES = 1 << 46;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PermissionFlags {
|
||||||
|
pub fn has_permission(&self, permission: PermissionFlags) -> bool {
|
||||||
|
self.contains(permission) || self.contains(PermissionFlags::ADMINISTRATOR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue