Skip to main content

zaun_community_protocol/command/object/
role.rs

1//! The role object (specification §8.4, permissions §2.1).
2
3use serde::{Deserialize, Serialize};
4
5use crate::bits::Permissions;
6use crate::ids::RoleId;
7
8pub use crate::limits::COLOR_MAX;
9
10/// A role (§8.4). Visible to every member.
11#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
12pub struct Role {
13    /// Host-assigned id; all-zero for `@everyone`.
14    pub role_id: RoleId,
15    /// 1–100 scalars.
16    pub name: String,
17    /// RGB `0x000000`–`0xFFFFFF`, or none.
18    pub color: Option<u32>,
19    /// Shown separately in member lists.
20    pub hoist: bool,
21    /// May be mentioned by anyone.
22    pub mentionable: bool,
23    /// 0 for `@everyone`; 1..n otherwise, higher = more authority.
24    pub position: u32,
25    /// Granted bits; unknown bits are preserved (permissions §1.2).
26    pub permissions: Permissions,
27    /// Only on a bot's managed role (§8.13).
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    pub managed_by: Option<crate::ids::BotId>,
30}
31
32/// One entry of `role.reorder` and `role.reordered` (§8.4, §9.2).
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
34pub struct RolePosition {
35    /// The role moved.
36    pub role_id: RoleId,
37    /// Its new position (≥ 1).
38    pub position: u32,
39}