spectacles_model/guild/
role.rs1use crate::snowflake::Snowflake;
2
3#[derive(Clone, Debug, Serialize, Deserialize)]
5pub struct Role {
6 pub id: Snowflake,
8 pub name: String,
10 pub color: i32,
12 #[serde(rename = "hoist")]
14 pub hoisted: bool,
15 pub position: i32,
17 pub managed: bool,
19 pub mentionable: bool
21}
22
23#[derive(Clone, Debug, Deserialize, Serialize, Default)]
25pub struct CreateRoleOptions {
26 #[serde(skip_serializing_if = "Option::is_none")]
27 name: Option<String>,
28 #[serde(skip_serializing_if = "Option::is_none")]
29 permissions: Option<i32>,
30 #[serde(skip_serializing_if = "Option::is_none")]
31 color: Option<i32>,
32 #[serde(skip_serializing_if = "Option::is_none")]
33 hoist: Option<bool>,
34 #[serde(skip_serializing_if = "Option::is_none")]
35 mentionable: Option<bool>,
36}
37
38impl CreateRoleOptions {
39 pub fn name(mut self, name: &str) -> Self {
41 self.name = Some(name.to_string());
42 self
43 }
44
45 pub fn permissions(mut self, perms: i32) -> Self {
47 self.permissions = Some(perms);
48 self
49 }
50
51 pub fn color(mut self, clr: i32) -> Self {
53 self.color = Some(clr);
54 self
55 }
56
57 pub fn hoisted(mut self, opt: bool) -> Self {
59 self.hoist = Some(opt);
60 self
61 }
62
63 pub fn mentionable(mut self, opt: bool) -> Self {
65 self.mentionable = Some(opt);
66 self
67 }
68}
69
70#[derive(Clone, Debug, Deserialize, Serialize, Default)]
72pub struct ModifyRoleOptions {
73 #[serde(skip_serializing_if = "Option::is_none")]
74 name: Option<String>,
75 #[serde(skip_serializing_if = "Option::is_none")]
76 permissions: Option<i32>,
77 #[serde(skip_serializing_if = "Option::is_none")]
78 color: Option<i32>,
79 #[serde(skip_serializing_if = "Option::is_none")]
80 hoist: Option<bool>,
81 #[serde(skip_serializing_if = "Option::is_none")]
82 mentionable: Option<bool>,
83}
84
85impl ModifyRoleOptions {
86 pub fn name(mut self, name: &str) -> Self {
88 self.name = Some(name.to_string());
89 self
90 }
91
92 pub fn permissions(mut self, perms: i32) -> Self {
94 self.permissions = Some(perms);
95 self
96 }
97
98 pub fn color(mut self, clr: i32) -> Self {
100 self.color = Some(clr);
101 self
102 }
103
104 pub fn hoisted(mut self, opt: bool) -> Self {
106 self.hoist = Some(opt);
107 self
108 }
109
110 pub fn mentionable(mut self, opt: bool) -> Self {
112 self.mentionable = Some(opt);
113 self
114 }
115}
116
117#[derive(Clone, Debug, Serialize, Deserialize)]
119pub struct GuildRoleCreateOrUpdate {
120 pub guild_id: Snowflake,
122 pub role: Role
124}
125
126#[derive(Clone, Debug, Serialize, Deserialize)]
128pub struct GuildRoleDelete {
129 pub guild_id: Snowflake,
131 pub role_id: Snowflake
133}