use crate::snowflake::Snowflake;
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Role {
pub id: Snowflake,
pub name: String,
pub color: i32,
#[serde(rename = "hoist")]
pub hoisted: bool,
pub position: i32,
pub managed: bool,
pub mentionable: bool
}
#[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub struct CreateRoleOptions {
#[serde(skip_serializing_if = "Option::is_none")]
name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
permissions: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
color: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
hoist: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
mentionable: Option<bool>,
}
impl CreateRoleOptions {
pub fn name(mut self, name: &str) -> Self {
self.name = Some(name.to_string());
self
}
pub fn permissions(mut self, perms: i32) -> Self {
self.permissions = Some(perms);
self
}
pub fn color(mut self, clr: i32) -> Self {
self.color = Some(clr);
self
}
pub fn hoisted(mut self, opt: bool) -> Self {
self.hoist = Some(opt);
self
}
pub fn mentionable(mut self, opt: bool) -> Self {
self.mentionable = Some(opt);
self
}
}
#[derive(Clone, Debug, Deserialize, Serialize, Default)]
pub struct ModifyRoleOptions {
#[serde(skip_serializing_if = "Option::is_none")]
name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
permissions: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
color: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
hoist: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
mentionable: Option<bool>,
}
impl ModifyRoleOptions {
pub fn name(mut self, name: &str) -> Self {
self.name = Some(name.to_string());
self
}
pub fn permissions(mut self, perms: i32) -> Self {
self.permissions = Some(perms);
self
}
pub fn color(mut self, clr: i32) -> Self {
self.color = Some(clr);
self
}
pub fn hoisted(mut self, opt: bool) -> Self {
self.hoist = Some(opt);
self
}
pub fn mentionable(mut self, opt: bool) -> Self {
self.mentionable = Some(opt);
self
}
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GuildRoleCreateOrUpdate {
pub guild_id: Snowflake,
pub role: Role
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GuildRoleDelete {
pub guild_id: Snowflake,
pub role_id: Snowflake
}