use internal::prelude::*;
use model::prelude::*;
use utils::VecMap;
#[derive(Clone, Debug, Default)]
pub struct EditGuild(pub VecMap<&'static str, Value>);
impl EditGuild {
#[inline]
pub fn afk_channel<C: Into<ChannelId>>(self, channel: Option<C>) -> Self {
self._afk_channel(channel.map(Into::into))
}
fn _afk_channel(mut self, channel: Option<ChannelId>) -> Self {
self.0.insert(
"afk_channel_id",
match channel {
Some(channel) => Value::Number(Number::from(channel.0)),
None => Value::Null,
},
);
self
}
pub fn afk_timeout(mut self, timeout: u64) -> Self {
self.0.insert(
"afk_timeout",
Value::Number(Number::from(timeout)),
);
self
}
pub fn icon(mut self, icon: Option<&str>) -> Self {
self.0.insert(
"icon",
icon.map_or_else(|| Value::Null, |x| Value::String(x.to_string())),
);
self
}
pub fn name(mut self, name: &str) -> Self {
self.0.insert("name", Value::String(name.to_string()));
self
}
#[inline]
pub fn owner<U: Into<UserId>>(self, user_id: U) -> Self {
self._owner(user_id.into())
}
fn _owner(mut self, user_id: UserId) -> Self {
let id = Value::Number(Number::from(user_id.0));
self.0.insert("owner_id", id);
self
}
pub fn region(mut self, region: Region) -> Self {
self.0.insert("region", Value::String(region.name().to_string()));
self
}
pub fn splash(mut self, splash: Option<&str>) -> Self {
let splash = splash.map_or(Value::Null, |x| Value::String(x.to_string()));
self.0.insert("splash", splash);
self
}
#[inline]
pub fn verification_level<V>(self, verification_level: V) -> Self
where V: Into<VerificationLevel> {
self._verification_level(verification_level.into())
}
fn _verification_level(mut self, verification_level: VerificationLevel) -> Self {
let num = Value::Number(Number::from(verification_level.num()));
self.0.insert("verification_level", num);
self
}
}