diff options
Diffstat (limited to 'src/builder/edit_guild.rs')
| -rw-r--r-- | src/builder/edit_guild.rs | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/builder/edit_guild.rs b/src/builder/edit_guild.rs index 0719305..a4f2c54 100644 --- a/src/builder/edit_guild.rs +++ b/src/builder/edit_guild.rs @@ -22,13 +22,14 @@ impl EditGuild { /// valid. /// /// [`afk_timeout`]: #method.afk_timeout - pub fn afk_channel<C: Into<ChannelId>>(mut self, channel: Option<C>) -> Self { + pub fn afk_channel<C: Into<ChannelId>>(self, channel: Option<C>) -> Self { + self._afk_channel(channel.map(|c| c.into())) + } + + fn _afk_channel(mut self, channel: Option<ChannelId>) -> Self { self.0.insert( "afk_channel_id".to_string(), - match channel { - Some(channel) => Value::Number(Number::from(channel.into().0)), - None => Value::Null, - }, + channel.map_or(Value::Null, |ChannelId(id)| Value::Number(Number::from(id))) ); self @@ -98,10 +99,14 @@ impl EditGuild { /// Transfers the ownership of the guild to another user by Id. /// /// **Note**: The current user must be the owner of the guild. - pub fn owner<U: Into<UserId>>(mut self, user_id: U) -> Self { + pub fn owner<U: Into<UserId>>(self, user_id: U) -> Self { + self._owner(user_id.into()) + } + + fn _owner(mut self, user_id: UserId) -> Self { self.0.insert( "owner_id".to_string(), - Value::Number(Number::from(user_id.into().0)), + Value::Number(Number::from(user_id.0)), ); self @@ -185,9 +190,13 @@ impl EditGuild { /// /// [`VerificationLevel`]: ../model/enum.VerificationLevel.html /// [`VerificationLevel::High`]: ../model/enum.VerificationLevel.html#variant.High - pub fn verification_level<V>(mut self, verification_level: V) -> Self + pub fn verification_level<V>(self, verification_level: V) -> Self where V: Into<VerificationLevel> { - let num = Value::Number(Number::from(verification_level.into().num())); + 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".to_string(), num); |