diff options
| author | Zeyla Hellyer <[email protected]> | 2017-09-09 08:23:21 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-09-09 08:23:21 -0700 |
| commit | 1c138a357b37e3bd8002109cfb9a8da94a53810e (patch) | |
| tree | 3256df54f6b31e0422848ea6bcc1d35e58b27eee /src/model | |
| parent | `parent_id` -> `category_id` (diff) | |
| download | serenity-1c138a357b37e3bd8002109cfb9a8da94a53810e.tar.xz serenity-1c138a357b37e3bd8002109cfb9a8da94a53810e.zip | |
Apply rustfmt + fix tests
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel/channel_category.rs | 23 | ||||
| -rw-r--r-- | src/model/channel/guild_channel.rs | 6 | ||||
| -rw-r--r-- | src/model/channel/message.rs | 1 | ||||
| -rw-r--r-- | src/model/guild/member.rs | 7 | ||||
| -rw-r--r-- | src/model/guild/mod.rs | 2 | ||||
| -rw-r--r-- | src/model/utils.rs | 3 |
6 files changed, 31 insertions, 11 deletions
diff --git a/src/model/channel/channel_category.rs b/src/model/channel/channel_category.rs index a0673fd..29f6b36 100644 --- a/src/model/channel/channel_category.rs +++ b/src/model/channel/channel_category.rs @@ -104,9 +104,26 @@ impl ChannelCategory { let edited = f(EditChannel(map)).0; http::edit_channel(self.id.0, &edited).map(|channel| { - let GuildChannel { id, category_id, permission_overwrites, nsfw, name, position, kind, .. } = channel; + let GuildChannel { + id, + category_id, + permission_overwrites, + nsfw, + name, + position, + kind, + .. + } = channel; - *self = ChannelCategory { id, category_id, permission_overwrites, nsfw, name, position, kind }; + *self = ChannelCategory { + id, + category_id, + permission_overwrites, + nsfw, + name, + position, + kind, + }; () }) } @@ -119,4 +136,4 @@ impl ChannelCategory { /// Returns the name of the category. pub fn name(&self) -> &str { &self.name } -}
\ No newline at end of file +} diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index 8ae50a6..3e33102 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -24,13 +24,13 @@ pub struct GuildChannel { /// /// The default channel Id shares the Id of the guild and the default role. pub id: ChannelId, - /// Whether this guild channel belongs in a category. - #[serde(rename = "parent_id")] - pub category_id: Option<ChannelId>, /// The bitrate of the channel. /// /// **Note**: This is only available for voice channels. pub bitrate: Option<u64>, + /// Whether this guild channel belongs in a category. + #[serde(rename = "parent_id")] + pub category_id: Option<ChannelId>, /// The Id of the guild the channel is located in. /// /// If this matches with the [`id`], then this is the default text channel. diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs index 27f4e31..03aea16 100644 --- a/src/model/channel/message.rs +++ b/src/model/channel/message.rs @@ -97,6 +97,7 @@ impl Message { /// /// command!(channel_name(_ctx, msg) { /// let _ = match msg.channel() { + /// Some(Channel::Category(c)) => msg.reply(&c.read().unwrap().name), /// Some(Channel::Group(c)) => msg.reply(&c.read().unwrap().name()), /// Some(Channel::Guild(c)) => msg.reply(&c.read().unwrap().name), /// Some(Channel::Private(c)) => { diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs index d9ac230..6873dc7 100644 --- a/src/model/guild/member.rs +++ b/src/model/guild/member.rs @@ -274,8 +274,9 @@ impl Member { /// /// Returns a [`ModelError::GuildNotFound`] if the guild the member's in could not be /// found in the cache. - /// - /// And/or returns [`ModelError::ItemMissing`] if the "default channel" of the guild is not found. + /// + /// And/or returns [`ModelError::ItemMissing`] if the "default channel" of the guild is not + /// found. /// /// [`ModelError::GuildNotFound`]: enum.ModelError.html#variant.GuildNotFound /// [`ModelError::ItemMissing`]: enum.ModelError.html#variant.ItemMissing @@ -292,7 +293,7 @@ impl Member { Some(dc) => dc, None => return Err(From::from(ModelError::ItemMissing)), }; - + Ok(guild.permissions_for( default_channel.id, self.user.read().unwrap().id, diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index 714cf5c..47f789e 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -207,7 +207,7 @@ impl Guild { /// [`Guild::ban`]: struct.Guild.html#method.ban /// [`User`]: struct.User.html /// [Ban Members]: permissions/constant.BAN_MEMBERS.html - pub fn ban<U: Into<UserId>, BO: BanOptions>(&self, user: U, options: BO) -> Result<()> { + pub fn ban<U: Into<UserId>, BO: BanOptions>(&self, user: U, options: BO) -> Result<()> { #[cfg(feature = "cache")] { let req = permissions::BAN_MEMBERS; diff --git a/src/model/utils.rs b/src/model/utils.rs index 123f683..89d498a 100644 --- a/src/model/utils.rs +++ b/src/model/utils.rs @@ -160,7 +160,8 @@ pub fn user_has_perms(channel_id: ChannelId, mut permissions: Permissions) -> Re Channel::Group(_) | Channel::Private(_) | Channel::Category(_) => { - // Both users in DMs, and all users in groups and maybe all channels in categories will have the same + // Both users in DMs, and all users in groups and maybe all channels in categories will + // have the same // permissions. // // The only exception to this is when the current user is blocked by |