diff options
| author | Austin Hellyer <[email protected]> | 2016-11-25 20:06:47 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-25 20:06:47 -0800 |
| commit | adde653dc4797faf8094816da46f8e4430b33c98 (patch) | |
| tree | 229acc0e3d130bb44d53f09fef0716f2c16915af /src/model | |
| parent | Fix permission check on Message::delete (diff) | |
| download | serenity-adde653dc4797faf8094816da46f8e4430b33c98.tar.xz serenity-adde653dc4797faf8094816da46f8e4430b33c98.zip | |
Rename PublicChannel to GuildChannel
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel.rs | 34 | ||||
| -rw-r--r-- | src/model/gateway.rs | 4 | ||||
| -rw-r--r-- | src/model/guild.rs | 8 | ||||
| -rw-r--r-- | src/model/id.rs | 6 | ||||
| -rw-r--r-- | src/model/mod.rs | 8 | ||||
| -rw-r--r-- | src/model/permissions.rs | 2 | ||||
| -rw-r--r-- | src/model/utils.rs | 4 |
7 files changed, 33 insertions, 33 deletions
diff --git a/src/model/channel.rs b/src/model/channel.rs index 8911487..64e7c71 100644 --- a/src/model/channel.rs +++ b/src/model/channel.rs @@ -195,8 +195,8 @@ impl Channel { pub fn decode(value: Value) -> Result<Channel> { let map = try!(into_map(value)); match req!(map.get("type").and_then(|x| x.as_u64())) { - 0 | 2 => PublicChannel::decode(Value::Object(map)) - .map(Channel::Public), + 0 | 2 => GuildChannel::decode(Value::Object(map)) + .map(Channel::Guild), 1 => PrivateChannel::decode(Value::Object(map)) .map(Channel::Private), 3 => Group::decode(Value::Object(map)) @@ -218,28 +218,28 @@ impl Channel { Channel::Group(ref group) => { let _ = try!(group.leave()); }, + Channel::Guild(ref public_channel) => { + let _ = try!(public_channel.delete()); + }, Channel::Private(ref private_channel) => { let _ = try!(private_channel.delete()); }, - Channel::Public(ref public_channel) => { - let _ = try!(public_channel.delete()); - }, } Ok(()) } - /// Retrieves the Id of the inner [`Group`], [`PublicChannel`], or + /// Retrieves the Id of the inner [`Group`], [`GuildChannel`], or /// [`PrivateChannel`]. /// /// [`Group`]: struct.Group.html - /// [`PublicChannel`]: struct.PublicChannel.html + /// [`GuildChannel`]: struct.GuildChannel.html /// [`PrivateChannel`]: struct.PrivateChannel.html pub fn id(&self) -> ChannelId { match *self { Channel::Group(ref group) => group.channel_id, + Channel::Guild(ref channel) => channel.id, Channel::Private(ref channel) => channel.id, - Channel::Public(ref channel) => channel.id, } } } @@ -251,18 +251,18 @@ impl fmt::Display for Channel { /// /// - [`Group`]s: the generated name retrievable via [`Group::name`]; /// - [`PrivateChannel`]s: the recipient's name; - /// - [`PublicChannel`]s: a string mentioning the channel that users who can + /// - [`GuildChannel`]s: a string mentioning the channel that users who can /// see the channel can click on. /// /// [`Group`]: struct.Group.html /// [`Group::name`]: struct.Group.html#method.name - /// [`PublicChannel`]: struct.PublicChannel.html + /// [`GuildChannel`]: struct.GuildChannel.html /// [`PrivateChannel`]: struct.PrivateChannel.html fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let out = match *self { Channel::Group(ref group) => group.name().to_owned(), + Channel::Guild(ref channel) => Cow::Owned(format!("{}", channel)), Channel::Private(ref channel) => Cow::Owned(channel.recipient.name.clone()), - Channel::Public(ref channel) => Cow::Owned(format!("{}", channel)), }; fmt::Display::fmt(&out, f) @@ -784,7 +784,7 @@ impl fmt::Display for PrivateChannel { } } -impl PublicChannel { +impl GuildChannel { /// Broadcasts to the channel that the current user is typing. /// /// For bots, this is a good indicator for long-running commands. @@ -819,18 +819,18 @@ impl PublicChannel { } #[doc(hidden)] - pub fn decode(value: Value) -> Result<PublicChannel> { + pub fn decode(value: Value) -> Result<GuildChannel> { let mut map = try!(into_map(value)); let id = try!(remove(&mut map, "guild_id").and_then(GuildId::decode)); - PublicChannel::decode_guild(Value::Object(map), id) + GuildChannel::decode_guild(Value::Object(map), id) } #[doc(hidden)] - pub fn decode_guild(value: Value, guild_id: GuildId) -> Result<PublicChannel> { + pub fn decode_guild(value: Value, guild_id: GuildId) -> Result<GuildChannel> { let mut map = try!(into_map(value)); - missing!(map, PublicChannel { + missing!(map, GuildChannel { id: try!(remove(&mut map, "id").and_then(ChannelId::decode)), name: try!(remove(&mut map, "name").and_then(into_string)), guild_id: guild_id, @@ -954,7 +954,7 @@ impl PublicChannel { } } -impl fmt::Display for PublicChannel { +impl fmt::Display for GuildChannel { /// Formas the channel, creating a mention of it. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(&self.mention(), f) diff --git a/src/model/gateway.rs b/src/model/gateway.rs index d12205b..c867a00 100644 --- a/src/model/gateway.rs +++ b/src/model/gateway.rs @@ -462,10 +462,10 @@ pub enum Event { VoiceStateUpdate(VoiceStateUpdateEvent), /// Voice server information is available VoiceServerUpdate(VoiceServerUpdateEvent), - /// A webhook for a [channel][`PublicChannel`] was updated in a [`Guild`]. + /// A webhook for a [channel][`GuildChannel`] was updated in a [`Guild`]. /// /// [`Guild`]: struct.Guild.html - /// [`PublicChannel`]: struct.PublicChannel.html + /// [`GuildChannel`]: struct.GuildChannel.html WebhookUpdate(WebhookUpdateEvent), /// An event type not covered by the above Unknown(UnknownEvent), diff --git a/src/model/guild.rs b/src/model/guild.rs index 33adc80..9cfbd7e 100644 --- a/src/model/guild.rs +++ b/src/model/guild.rs @@ -331,7 +331,7 @@ impl Guild { let mut public_channels = HashMap::new(); let vals = try!(decode_array(try!(remove(&mut map, "channels")), - |v| PublicChannel::decode_guild(v, id))); + |v| GuildChannel::decode_guild(v, id))); for public_channel in vals { public_channels.insert(public_channel.id, public_channel); @@ -461,11 +461,11 @@ impl Guild { rest::edit_nickname(self.id.0, new_nickname) } - /// Attempts to retrieve a [`PublicChannel`] with the given Id. + /// Attempts to retrieve a [`GuildChannel`] with the given Id. /// - /// [`PublicChannel`]: struct.PublicChannel.html + /// [`GuildChannel`]: struct.GuildChannel.html pub fn get_channel<C: Into<ChannelId>>(&self, channel_id: C) - -> Option<&PublicChannel> { + -> Option<&GuildChannel> { self.channels.get(&channel_id.into()) } diff --git a/src/model/id.rs b/src/model/id.rs index d7d131a..7cc4f31 100644 --- a/src/model/id.rs +++ b/src/model/id.rs @@ -53,8 +53,8 @@ impl From<Channel> for ChannelId { fn from(channel: Channel) -> ChannelId { match channel { Channel::Group(group) => group.channel_id, + Channel::Guild(channel) => channel.id, Channel::Private(channel) => channel.id, - Channel::Public(channel) => channel.id, } } } @@ -65,8 +65,8 @@ impl From<PrivateChannel> for ChannelId { } } -impl From<PublicChannel> for ChannelId { - fn from(public_channel: PublicChannel) -> ChannelId { +impl From<GuildChannel> for ChannelId { + fn from(public_channel: GuildChannel) -> ChannelId { public_channel.id } } diff --git a/src/model/mod.rs b/src/model/mod.rs index 880be42..5d1540b 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -124,15 +124,15 @@ id! { pub enum Channel { /// A group. A group comprises of only one channel. Group(Group), - /// A private channel to another [`User`]. No other users may access the - /// channel. For multi-user "private channels", use a group. - Private(PrivateChannel), /// A [text] or [voice] channel within a [`Guild`]. /// /// [`Guild`]: struct.Guild.html /// [text]: enum.ChannelType.html#variant.Text /// [voice]: enum.ChannelType.html#variant.Voice - Public(PublicChannel), + Guild(GuildChannel), + /// A private channel to another [`User`]. No other users may access the + /// channel. For multi-user "private channels", use a group. + Private(PrivateChannel), } /// A container for guilds. diff --git a/src/model/permissions.rs b/src/model/permissions.rs index cb9a061..3f164fe 100644 --- a/src/model/permissions.rs +++ b/src/model/permissions.rs @@ -169,7 +169,7 @@ bitflags! { const ADMINISTRATOR = 1 << 3, /// Allows management and editing of guild [channel]s. /// - /// [channel]: ../struct.PublicChannel.html + /// [channel]: ../struct.GuildChannel.html const MANAGE_CHANNELS = 1 << 4, /// Allows management and editing of the [guild]. /// diff --git a/src/model/utils.rs b/src/model/utils.rs index a995758..23fdfc5 100644 --- a/src/model/utils.rs +++ b/src/model/utils.rs @@ -143,7 +143,7 @@ pub fn decode_private_channels(value: Value) let id = match private_channel { Channel::Group(ref group) => group.channel_id, Channel::Private(ref channel) => channel.id, - Channel::Public(_) => unreachable!("Public private channel decode"), + Channel::Guild(_) => unreachable!("Guild private channel decode"), }; private_channels.insert(id, private_channel); @@ -287,7 +287,7 @@ pub fn user_has_perms(channel_id: ChannelId, Channel::Group(_) | Channel::Private(_) => { return Ok(permissions == permissions::MANAGE_MESSAGES); }, - Channel::Public(channel) => channel.guild_id, + Channel::Guild(channel) => channel.guild_id, }; let guild = match cache.get_guild(guild_id) { |