aboutsummaryrefslogtreecommitdiff
path: root/src/builder
diff options
context:
space:
mode:
authorMaiddog <[email protected]>2017-08-26 17:55:43 -0500
committeralex <[email protected]>2017-08-27 00:55:43 +0200
commit3e0b1032d80a1847558a752e8316d97f9ae58f04 (patch)
treeca65390091cb3c0ab98b6497a1447ba69df3d20d /src/builder
parentUse `$crate` for `Args` (diff)
downloadserenity-3e0b1032d80a1847558a752e8316d97f9ae58f04.tar.xz
serenity-3e0b1032d80a1847558a752e8316d97f9ae58f04.zip
Add ability to play DCA and Opus files. (#148)
Diffstat (limited to 'src/builder')
-rw-r--r--src/builder/create_embed.rs71
-rw-r--r--src/builder/create_invite.rs18
-rw-r--r--src/builder/create_message.rs8
-rw-r--r--src/builder/edit_channel.rs24
-rw-r--r--src/builder/edit_guild.rs19
-rw-r--r--src/builder/edit_member.rs8
-rw-r--r--src/builder/edit_profile.rs18
-rw-r--r--src/builder/edit_role.rs61
-rw-r--r--src/builder/execute_webhook.rs12
-rw-r--r--src/builder/get_messages.rs6
10 files changed, 168 insertions, 77 deletions
diff --git a/src/builder/create_embed.rs b/src/builder/create_embed.rs
index 1e0bc8d..6d61653 100644
--- a/src/builder/create_embed.rs
+++ b/src/builder/create_embed.rs
@@ -87,8 +87,10 @@ impl CreateEmbed {
/// Set the colour of the left-hand side of the embed.
#[cfg(not(feature = "utils"))]
pub fn colour(mut self, colour: u32) -> Self {
- self.0
- .insert("color".to_owned(), Value::Number(Number::from(colour)));
+ self.0.insert(
+ "color".to_owned(),
+ Value::Number(Number::from(colour)),
+ );
CreateEmbed(self.0)
}
@@ -282,24 +284,30 @@ impl CreateEmbed {
/// let mut client = Client::new("token", Handler); client.start().unwrap();
/// ```
pub fn timestamp<T: Into<Timestamp>>(mut self, timestamp: T) -> Self {
- self.0
- .insert("timestamp".to_owned(), Value::String(timestamp.into().ts));
+ self.0.insert(
+ "timestamp".to_owned(),
+ Value::String(timestamp.into().ts),
+ );
CreateEmbed(self.0)
}
/// Set the title of the embed.
pub fn title<D: Display>(mut self, title: D) -> Self {
- self.0
- .insert("title".to_owned(), Value::String(format!("{}", title)));
+ self.0.insert(
+ "title".to_owned(),
+ Value::String(format!("{}", title)),
+ );
CreateEmbed(self.0)
}
/// Set the URL to direct to when clicking on the title.
pub fn url(mut self, url: &str) -> Self {
- self.0
- .insert("url".to_owned(), Value::String(url.to_owned()));
+ self.0.insert(
+ "url".to_owned(),
+ Value::String(url.to_owned()),
+ );
CreateEmbed(self.0)
}
@@ -319,7 +327,10 @@ impl Default for CreateEmbed {
/// Creates a builder with default values, setting the `type` to `rich`.
fn default() -> CreateEmbed {
let mut map = Map::new();
- map.insert("type".to_owned(), Value::String("rich".to_owned()));
+ map.insert(
+ "type".to_owned(),
+ Value::String("rich".to_owned()),
+ );
CreateEmbed(map)
}
@@ -396,24 +407,30 @@ pub struct CreateEmbedAuthor(pub Map<String, Value>);
impl CreateEmbedAuthor {
/// Set the URL of the author's icon.
pub fn icon_url(mut self, icon_url: &str) -> Self {
- self.0
- .insert("icon_url".to_owned(), Value::String(icon_url.to_owned()));
+ self.0.insert(
+ "icon_url".to_owned(),
+ Value::String(icon_url.to_owned()),
+ );
self
}
/// Set the author's name.
pub fn name(mut self, name: &str) -> Self {
- self.0
- .insert("name".to_owned(), Value::String(name.to_owned()));
+ self.0.insert(
+ "name".to_owned(),
+ Value::String(name.to_owned()),
+ );
self
}
/// Set the author's URL.
pub fn url(mut self, url: &str) -> Self {
- self.0
- .insert("url".to_owned(), Value::String(url.to_owned()));
+ self.0.insert(
+ "url".to_owned(),
+ Value::String(url.to_owned()),
+ );
self
}
@@ -440,16 +457,20 @@ impl CreateEmbedField {
/// Set the field's name. It can't be longer than 256 characters.
pub fn name<D: Display>(mut self, name: D) -> Self {
- self.0
- .insert("name".to_owned(), Value::String(format!("{}", name)));
+ self.0.insert(
+ "name".to_owned(),
+ Value::String(format!("{}", name)),
+ );
self
}
/// Set the field's value. It can't be longer than 1024 characters.
pub fn value<D: Display>(mut self, value: D) -> Self {
- self.0
- .insert("value".to_owned(), Value::String(format!("{}", value)));
+ self.0.insert(
+ "value".to_owned(),
+ Value::String(format!("{}", value)),
+ );
self
}
@@ -479,16 +500,20 @@ pub struct CreateEmbedFooter(pub Map<String, Value>);
impl CreateEmbedFooter {
/// Set the icon URL's value. This only supports HTTP(S).
pub fn icon_url(mut self, icon_url: &str) -> Self {
- self.0
- .insert("icon_url".to_owned(), Value::String(icon_url.to_owned()));
+ self.0.insert(
+ "icon_url".to_owned(),
+ Value::String(icon_url.to_owned()),
+ );
self
}
/// Set the footer's text.
pub fn text<D: Display>(mut self, text: D) -> Self {
- self.0
- .insert("text".to_owned(), Value::String(format!("{}", text)));
+ self.0.insert(
+ "text".to_owned(),
+ Value::String(format!("{}", text)),
+ );
self
}
diff --git a/src/builder/create_invite.rs b/src/builder/create_invite.rs
index 58893fc..d17f273 100644
--- a/src/builder/create_invite.rs
+++ b/src/builder/create_invite.rs
@@ -89,8 +89,10 @@ impl CreateInvite {
/// # }
/// ```
pub fn max_age(mut self, max_age: u64) -> Self {
- self.0
- .insert("max_age".to_owned(), Value::Number(Number::from(max_age)));
+ self.0.insert(
+ "max_age".to_owned(),
+ Value::Number(Number::from(max_age)),
+ );
self
}
@@ -123,8 +125,10 @@ impl CreateInvite {
/// # }
/// ```
pub fn max_uses(mut self, max_uses: u64) -> Self {
- self.0
- .insert("max_uses".to_owned(), Value::Number(Number::from(max_uses)));
+ self.0.insert(
+ "max_uses".to_owned(),
+ Value::Number(Number::from(max_uses)),
+ );
self
}
@@ -155,8 +159,10 @@ impl CreateInvite {
/// # }
/// ```
pub fn temporary(mut self, temporary: bool) -> Self {
- self.0
- .insert("temporary".to_owned(), Value::Bool(temporary));
+ self.0.insert(
+ "temporary".to_owned(),
+ Value::Bool(temporary),
+ );
self
}
diff --git a/src/builder/create_message.rs b/src/builder/create_message.rs
index 32cd781..1ac5211 100644
--- a/src/builder/create_message.rs
+++ b/src/builder/create_message.rs
@@ -46,8 +46,10 @@ impl CreateMessage {
///
/// **Note**: Message contents must be under 2000 unicode code points.
pub fn content<D: Display>(mut self, content: D) -> Self {
- self.0
- .insert("content".to_owned(), Value::String(format!("{}", content)));
+ self.0.insert(
+ "content".to_owned(),
+ Value::String(format!("{}", content)),
+ );
CreateMessage(self.0, self.1)
}
@@ -74,7 +76,7 @@ impl CreateMessage {
}
/// Adds a list of reactions to create after the message's sent.
-pub fn reactions<R: Into<ReactionType>>(mut self, reactions: Vec<R>) -> Self{
+ pub fn reactions<R: Into<ReactionType>>(mut self, reactions: Vec<R>) -> Self {
self.1 = Some(reactions.into_iter().map(|r| r.into()).collect());
CreateMessage(self.0, self.1)
diff --git a/src/builder/edit_channel.rs b/src/builder/edit_channel.rs
index e3bf78e..a5d799f 100644
--- a/src/builder/edit_channel.rs
+++ b/src/builder/edit_channel.rs
@@ -27,8 +27,10 @@ impl EditChannel {
///
/// [voice]: ../model/enum.ChannelType.html#variant.Voice
pub fn bitrate(mut self, bitrate: u64) -> Self {
- self.0
- .insert("bitrate".to_owned(), Value::Number(Number::from(bitrate)));
+ self.0.insert(
+ "bitrate".to_owned(),
+ Value::Number(Number::from(bitrate)),
+ );
self
}
@@ -37,16 +39,20 @@ impl EditChannel {
///
/// Must be between 2 and 100 characters long.
pub fn name(mut self, name: &str) -> Self {
- self.0
- .insert("name".to_owned(), Value::String(name.to_owned()));
+ self.0.insert(
+ "name".to_owned(),
+ Value::String(name.to_owned()),
+ );
self
}
/// The position of the channel in the channel list.
pub fn position(mut self, position: u64) -> Self {
- self.0
- .insert("position".to_owned(), Value::Number(Number::from(position)));
+ self.0.insert(
+ "position".to_owned(),
+ Value::Number(Number::from(position)),
+ );
self
}
@@ -59,8 +65,10 @@ impl EditChannel {
///
/// [text]: ../model/enum.ChannelType.html#variant.Text
pub fn topic(mut self, topic: &str) -> Self {
- self.0
- .insert("topic".to_owned(), Value::String(topic.to_owned()));
+ self.0.insert(
+ "topic".to_owned(),
+ Value::String(topic.to_owned()),
+ );
self
}
diff --git a/src/builder/edit_guild.rs b/src/builder/edit_guild.rs
index 0fca747..6cfd13a 100644
--- a/src/builder/edit_guild.rs
+++ b/src/builder/edit_guild.rs
@@ -22,7 +22,7 @@ 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>>(mut self, channel: Option<C>) -> Self {
self.0.insert(
"afk_channel_id".to_owned(),
match channel {
@@ -79,7 +79,10 @@ pub fn afk_channel<C: Into<ChannelId>>(mut self, channel: Option<C>) -> 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())),
+ icon.map_or_else(
+ || Value::Null,
+ |x| Value::String(x.to_owned()),
+ ),
);
self
@@ -89,8 +92,10 @@ pub fn afk_channel<C: Into<ChannelId>>(mut self, channel: Option<C>) -> Self{
///
/// **Note**: Must be between (and including) 2-100 chracters.
pub fn name(mut self, name: &str) -> Self {
- self.0
- .insert("name".to_owned(), Value::String(name.to_owned()));
+ self.0.insert(
+ "name".to_owned(),
+ Value::String(name.to_owned()),
+ );
self
}
@@ -134,8 +139,10 @@ pub fn afk_channel<C: Into<ChannelId>>(mut self, channel: Option<C>) -> Self{
///
/// [`Region::UsWest`]: ../model/enum.Region.html#variant.UsWest
pub fn region(mut self, region: Region) -> Self {
- self.0
- .insert("region".to_owned(), Value::String(region.name().to_owned()));
+ self.0.insert(
+ "region".to_owned(),
+ Value::String(region.name().to_owned()),
+ );
self
}
diff --git a/src/builder/edit_member.rs b/src/builder/edit_member.rs
index 9143640..80ec983 100644
--- a/src/builder/edit_member.rs
+++ b/src/builder/edit_member.rs
@@ -39,8 +39,10 @@ impl EditMember {
///
/// [Manage Nicknames]: ../model/permissions/constant.MANAGE_NICKNAMES.html
pub fn nickname(mut self, nickname: &str) -> Self {
- self.0
- .insert("nick".to_owned(), Value::String(nickname.to_owned()));
+ self.0.insert(
+ "nick".to_owned(),
+ Value::String(nickname.to_owned()),
+ );
self
}
@@ -66,7 +68,7 @@ impl EditMember {
/// Requires the [Move Members] permission.
///
/// [Move Members]: ../model/permissions/constant.MOVE_MEMBERS.html
-pub fn voice_channel<C: Into<ChannelId>>(mut self, channel_id: C) -> Self{
+ pub fn voice_channel<C: Into<ChannelId>>(mut self, channel_id: C) -> Self {
self.0.insert(
"channel_id".to_owned(),
Value::Number(Number::from(channel_id.into().0)),
diff --git a/src/builder/edit_profile.rs b/src/builder/edit_profile.rs
index 6aa4e78..3bc121c 100644
--- a/src/builder/edit_profile.rs
+++ b/src/builder/edit_profile.rs
@@ -61,8 +61,10 @@ impl EditProfile {
///
/// [provided]: #method.password
pub fn email(mut self, email: &str) -> Self {
- self.0
- .insert("email".to_owned(), Value::String(email.to_owned()));
+ self.0.insert(
+ "email".to_owned(),
+ Value::String(email.to_owned()),
+ );
self
}
@@ -88,8 +90,10 @@ impl EditProfile {
/// [modifying the password]: #method.new_password
/// [modifying the associated email address]: #method.email
pub fn password(mut self, password: &str) -> Self {
- self.0
- .insert("password".to_owned(), Value::String(password.to_owned()));
+ self.0.insert(
+ "password".to_owned(),
+ Value::String(password.to_owned()),
+ );
self
}
@@ -101,8 +105,10 @@ impl EditProfile {
/// If there are no available discriminators with the requested username,
/// an error will occur.
pub fn username(mut self, username: &str) -> Self {
- self.0
- .insert("username".to_owned(), Value::String(username.to_owned()));
+ self.0.insert(
+ "username".to_owned(),
+ Value::String(username.to_owned()),
+ );
self
}
diff --git a/src/builder/edit_role.rs b/src/builder/edit_role.rs
index 8be3404..d034149 100644
--- a/src/builder/edit_role.rs
+++ b/src/builder/edit_role.rs
@@ -1,6 +1,6 @@
use std::default::Default;
use internal::prelude::*;
-use model::{permissions, Permissions, Role};
+use model::{Permissions, Role, permissions};
/// A builer to create or edit a [`Role`] for use via a number of model methods.
///
@@ -58,13 +58,22 @@ impl EditRole {
#[cfg(not(feature = "utils"))]
{
- map.insert("color".to_owned(), Value::Number(Number::from(role.colour)));
+ map.insert(
+ "color".to_owned(),
+ Value::Number(Number::from(role.colour)),
+ );
}
map.insert("hoist".to_owned(), Value::Bool(role.hoist));
map.insert("managed".to_owned(), Value::Bool(role.managed));
- map.insert("mentionable".to_owned(), Value::Bool(role.mentionable));
- map.insert("name".to_owned(), Value::String(role.name.clone()));
+ map.insert(
+ "mentionable".to_owned(),
+ Value::Bool(role.mentionable),
+ );
+ map.insert(
+ "name".to_owned(),
+ Value::String(role.name.clone()),
+ );
map.insert(
"permissions".to_owned(),
Value::Number(Number::from(role.permissions.bits())),
@@ -79,8 +88,10 @@ impl EditRole {
/// Sets the colour of the role.
pub fn colour(mut self, colour: u64) -> Self {
- self.0
- .insert("color".to_owned(), Value::Number(Number::from(colour)));
+ self.0.insert(
+ "color".to_owned(),
+ Value::Number(Number::from(colour)),
+ );
self
}
@@ -95,16 +106,20 @@ impl EditRole {
/// Whether or not to make the role mentionable, notifying its users.
pub fn mentionable(mut self, mentionable: bool) -> Self {
- self.0
- .insert("mentionable".to_owned(), Value::Bool(mentionable));
+ self.0.insert(
+ "mentionable".to_owned(),
+ Value::Bool(mentionable),
+ );
self
}
/// The name of the role to set.
pub fn name(mut self, name: &str) -> Self {
- self.0
- .insert("name".to_owned(), Value::String(name.to_owned()));
+ self.0.insert(
+ "name".to_owned(),
+ Value::String(name.to_owned()),
+ );
self
}
@@ -122,8 +137,10 @@ impl EditRole {
/// The position to assign the role in the role list. This correlates to the
/// role's position in the user list.
pub fn position(mut self, position: u8) -> Self {
- self.0
- .insert("position".to_owned(), Value::Number(Number::from(position)));
+ self.0.insert(
+ "position".to_owned(),
+ Value::Number(Number::from(position)),
+ );
self
}
@@ -146,12 +163,24 @@ impl Default for EditRole {
let mut map = Map::new();
let permissions = Number::from(permissions::PRESET_GENERAL.bits());
- map.insert("color".to_owned(), Value::Number(Number::from(10_070_709)));
+ map.insert(
+ "color".to_owned(),
+ Value::Number(Number::from(10_070_709)),
+ );
map.insert("hoist".to_owned(), Value::Bool(false));
map.insert("mentionable".to_owned(), Value::Bool(false));
- map.insert("name".to_owned(), Value::String("new role".to_owned()));
- map.insert("permissions".to_owned(), Value::Number(permissions));
- map.insert("position".to_owned(), Value::Number(Number::from(1)));
+ map.insert(
+ "name".to_owned(),
+ Value::String("new role".to_owned()),
+ );
+ map.insert(
+ "permissions".to_owned(),
+ Value::Number(permissions),
+ );
+ map.insert(
+ "position".to_owned(),
+ Value::Number(Number::from(1)),
+ );
EditRole(map)
}
diff --git a/src/builder/execute_webhook.rs b/src/builder/execute_webhook.rs
index 0cb276c..05f0d00 100644
--- a/src/builder/execute_webhook.rs
+++ b/src/builder/execute_webhook.rs
@@ -103,8 +103,10 @@ impl ExecuteWebhook {
///
/// [`embeds`]: #method.embeds
pub fn content(mut self, content: &str) -> Self {
- self.0
- .insert("content".to_owned(), Value::String(content.to_owned()));
+ self.0.insert(
+ "content".to_owned(),
+ Value::String(content.to_owned()),
+ );
self
}
@@ -165,8 +167,10 @@ impl ExecuteWebhook {
/// }
/// ```
pub fn username(mut self, username: &str) -> Self {
- self.0
- .insert("username".to_owned(), Value::String(username.to_owned()));
+ self.0.insert(
+ "username".to_owned(),
+ Value::String(username.to_owned()),
+ );
self
}
diff --git a/src/builder/get_messages.rs b/src/builder/get_messages.rs
index bca2f0e..8ac5dfe 100644
--- a/src/builder/get_messages.rs
+++ b/src/builder/get_messages.rs
@@ -85,8 +85,10 @@ impl GetMessages {
/// limitation. If an amount larger than 100 is supplied, it will be
/// reduced.
pub fn limit(mut self, limit: u64) -> Self {
- self.0
- .insert("limit".to_owned(), if limit > 100 { 100 } else { limit });
+ self.0.insert(
+ "limit".to_owned(),
+ if limit > 100 { 100 } else { limit },
+ );
self
}