use serde::Serialize;
use crate::models::{events::ChannelField, Id};
#[derive(Debug, Clone, Serialize)]
pub struct CreateChannel {
r#type: ChannelType,
name: String,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
nsfw: bool,
}
#[derive(Debug, Clone, Serialize)]
enum ChannelType {
Text,
Voice,
}
impl CreateChannel {
pub fn text(name: impl Into<String>) -> Self {
Self {
r#type: ChannelType::Text,
name: name.into(),
description: None,
nsfw: false,
}
}
pub fn voice(name: impl Into<String>) -> Self {
Self {
r#type: ChannelType::Voice,
name: name.into(),
description: None,
nsfw: false,
}
}
pub fn description(mut self, description: impl Into<String>) -> Self {
self.description = Some(description.into());
self
}
pub fn nsfw(mut self, nsfw: bool) -> Self {
self.nsfw = nsfw;
self
}
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct EditChannel {
#[serde(skip_serializing_if = "Option::is_none")]
name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
icon: Option<Id>,
#[serde(skip_serializing_if = "Option::is_none")]
nsfw: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
remove: Option<ChannelField>,
}
impl EditChannel {
pub fn new() -> Self {
Self::default()
}
pub fn name(mut self, name: impl Into<String>) -> Self {
self.name = Some(name.into());
self
}
pub fn description(mut self, description: impl Into<String>) -> Self {
self.description = Some(description.into());
self
}
pub fn icon(mut self, id: &Id) -> Self {
self.icon = Some(id.clone());
self
}
pub fn nsfw(mut self, nsfw: bool) -> Self {
self.nsfw = Some(nsfw);
self
}
pub fn remove(mut self, field: ChannelField) -> Self {
self.remove = Some(field);
self
}
}