aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild/mod.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-09-18 17:48:52 -0700
committerZeyla Hellyer <[email protected]>2017-09-18 17:48:52 -0700
commitdae2cb77b407044f44a7a2790d93efba3891854e (patch)
treebef263c4490536cf8b56e988e71dd1aa43bc2696 /src/model/guild/mod.rs
parentFix compiles of a variety of feature combinations (diff)
downloadserenity-dae2cb77b407044f44a7a2790d93efba3891854e.tar.xz
serenity-dae2cb77b407044f44a7a2790d93efba3891854e.zip
Apply rustfmt
Diffstat (limited to 'src/model/guild/mod.rs')
-rw-r--r--src/model/guild/mod.rs90
1 files changed, 42 insertions, 48 deletions
diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs
index b4b0461..b668875 100644
--- a/src/model/guild/mod.rs
+++ b/src/model/guild/mod.rs
@@ -168,10 +168,7 @@ impl Guild {
None => return Err(Error::Model(ModelError::ItemMissing)),
};
- let perms = self.permissions_for(
- default_channel.id,
- member.user.read().unwrap().id,
- );
+ let perms = self.permissions_for(default_channel.id, member.user.read().unwrap().id);
permissions.remove(perms);
Ok(permissions.is_empty())
@@ -607,9 +604,9 @@ impl Guild {
/// Returns the formatted URL of the guild's icon, if one exists.
pub fn icon_url(&self) -> Option<String> {
- self.icon.as_ref().map(
- |icon| format!(cdn!("/icons/{}/{}.webp"), self.id, icon),
- )
+ self.icon
+ .as_ref()
+ .map(|icon| format!(cdn!("/icons/{}/{}.webp"), self.id, icon))
}
/// Gets all integration of the guild.
@@ -687,10 +684,8 @@ impl Guild {
for (&id, member) in &self.members {
match self.presences.get(&id) {
- Some(presence) => {
- if status == presence.status {
- members.push(member);
- }
+ Some(presence) => if status == presence.status {
+ members.push(member);
},
None => continue,
}
@@ -777,9 +772,11 @@ impl Guild {
let everyone = match self.roles.get(&RoleId(self.id.0)) {
Some(everyone) => everyone,
None => {
- error!("(╯°□°)╯︵ ┻━┻ @everyone role ({}) missing in '{}'",
- self.id,
- self.name);
+ error!(
+ "(╯°□°)╯︵ ┻━┻ @everyone role ({}) missing in '{}'",
+ self.id,
+ self.name
+ );
return Permissions::empty();
},
@@ -797,10 +794,12 @@ impl Guild {
if let Some(role) = self.roles.get(&role) {
permissions |= role.permissions;
} else {
- warn!("(╯°□°)╯︵ ┻━┻ {} on {} has non-existent role {:?}",
- member.user.read().unwrap().id,
- self.id,
- role);
+ warn!(
+ "(╯°□°)╯︵ ┻━┻ {} on {} has non-existent role {:?}",
+ member.user.read().unwrap().id,
+ self.id,
+ role
+ );
}
}
@@ -814,8 +813,8 @@ impl Guild {
// If this is a text channel, then throw out voice permissions.
if channel.kind == ChannelType::Text {
- permissions &= !(CONNECT | SPEAK | MUTE_MEMBERS | DEAFEN_MEMBERS | MOVE_MEMBERS |
- USE_VAD);
+ permissions &=
+ !(CONNECT | SPEAK | MUTE_MEMBERS | DEAFEN_MEMBERS | MOVE_MEMBERS | USE_VAD);
}
// Apply the permission overwrites for the channel for each of the
@@ -845,9 +844,11 @@ impl Guild {
permissions = (permissions & !overwrite.deny) | overwrite.allow;
}
} else {
- warn!("(╯°□°)╯︵ ┻━┻ Guild {} does not contain channel {}",
- self.id,
- channel_id);
+ warn!(
+ "(╯°□°)╯︵ ┻━┻ Guild {} does not contain channel {}",
+ self.id,
+ channel_id
+ );
}
// The default channel is always readable.
@@ -941,9 +942,9 @@ impl Guild {
/// Returns the formatted URL of the guild's splash image, if one exists.
pub fn splash_url(&self) -> Option<String> {
- self.icon.as_ref().map(
- |icon| format!(cdn!("/splashes/{}/{}.webp"), self.id, icon),
- )
+ self.icon
+ .as_ref()
+ .map(|icon| format!(cdn!("/splashes/{}/{}.webp"), self.id, icon))
}
/// Starts an integration sync for the given integration Id.
@@ -1057,18 +1058,16 @@ impl<'de> Deserialize<'de> for Guild {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> StdResult<Self, D::Error> {
let mut map = JsonMap::deserialize(deserializer)?;
- let id = map.get("id").and_then(|x| x.as_str()).and_then(|x| {
- x.parse::<u64>().ok()
- });
+ let id = map.get("id")
+ .and_then(|x| x.as_str())
+ .and_then(|x| x.parse::<u64>().ok());
if let Some(guild_id) = id {
if let Some(array) = map.get_mut("channels").and_then(|x| x.as_array_mut()) {
for value in array {
if let Some(channel) = value.as_object_mut() {
- channel.insert(
- "guild_id".to_owned(),
- Value::Number(Number::from(guild_id)),
- );
+ channel
+ .insert("guild_id".to_owned(), Value::Number(Number::from(guild_id)));
}
}
}
@@ -1076,21 +1075,16 @@ impl<'de> Deserialize<'de> for Guild {
if let Some(array) = map.get_mut("members").and_then(|x| x.as_array_mut()) {
for value in array {
if let Some(member) = value.as_object_mut() {
- member.insert(
- "guild_id".to_owned(),
- Value::Number(Number::from(guild_id)),
- );
+ member
+ .insert("guild_id".to_owned(), Value::Number(Number::from(guild_id)));
}
}
}
}
let afk_channel_id = match map.remove("afk_channel_id") {
- Some(v) => {
- serde_json::from_value::<Option<ChannelId>>(v).map_err(
- DeError::custom,
- )?
- },
+ Some(v) => serde_json::from_value::<Option<ChannelId>>(v)
+ .map_err(DeError::custom)?,
None => None,
};
let afk_timeout = map.remove("afk_timeout")
@@ -1242,9 +1236,9 @@ pub struct GuildInfo {
impl GuildInfo {
/// Returns the formatted URL of the guild's icon, if the guild has an icon.
pub fn icon_url(&self) -> Option<String> {
- self.icon.as_ref().map(
- |icon| format!(cdn!("/icons/{}/{}.webp"), self.id, icon),
- )
+ self.icon
+ .as_ref()
+ .map(|icon| format!(cdn!("/icons/{}/{}.webp"), self.id, icon))
}
}
@@ -1264,9 +1258,9 @@ impl From<u64> for GuildContainer {
impl InviteGuild {
/// Returns the formatted URL of the guild's splash image, if one exists.
pub fn splash_url(&self) -> Option<String> {
- self.icon.as_ref().map(
- |icon| format!(cdn!("/splashes/{}/{}.webp"), self.id, icon),
- )
+ self.icon
+ .as_ref()
+ .map(|icon| format!(cdn!("/splashes/{}/{}.webp"), self.id, icon))
}
}