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