Skip to content

Commit

Permalink
Make Guild::create_channel return a GuildChannel
Browse files Browse the repository at this point in the history
Instead of returning a generic `Channel` enum, make the following
functions return an explicit GuildChannel instead of a more "generic"
Channel enum:

- Guild::create_channel
- GuildId::create_channel
- PartialGuild::create_channel
- rest::create_channel
  • Loading branch information
Austin Hellyer committed Jan 25, 2017
1 parent 3ca7ad9 commit 5918d01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/client/rest/mod.rs
Expand Up @@ -204,14 +204,14 @@ pub fn broadcast_typing(channel_id: u64) -> Result<()> {
/// [`GuildChannel`]: ../../model/struct.GuildChannel.html
/// [docs]: https://discordapp.com/developers/docs/resources/guild#create-guild-channel
/// [Manage Channels]: ../../model/permissions/constant.MANAGE_CHANNELS.html
pub fn create_channel(guild_id: u64, map: Value) -> Result<Channel> {
pub fn create_channel(guild_id: u64, map: Value) -> Result<GuildChannel> {
let body = serde_json::to_string(&map)?;
let response = request!(Route::GuildsIdChannels(guild_id),
post(body),
"/guilds/{}/channels",
guild_id);

Channel::decode(serde_json::from_reader(response)?)
GuildChannel::decode(serde_json::from_reader(response)?)
}

/// Creates an emoji in the given [`Guild`] with the given data.
Expand Down
6 changes: 3 additions & 3 deletions src/model/guild.rs
Expand Up @@ -296,7 +296,7 @@ impl Guild {
/// [`Channel`]: struct.Channel.html
/// [`ClientError::InvalidPermissions`]: ../client/enum.ClientError.html#variant.InvalidPermissions
/// [Manage Channels]: permissions/constant.MANAGE_CHANNELS.html
pub fn create_channel(&mut self, name: &str, kind: ChannelType) -> Result<Channel> {
pub fn create_channel(&mut self, name: &str, kind: ChannelType) -> Result<GuildChannel> {
#[cfg(feature="cache")]
{
let req = permissions::MANAGE_CHANNELS;
Expand Down Expand Up @@ -1170,7 +1170,7 @@ impl GuildId {
/// [`GuildChannel`]: struct.GuildChannel.html
/// [`rest::create_channel`]: ../client/rest/fn.create_channel.html
/// [Manage Channels]: permissions/constant.MANAGE_CHANNELS.html
pub fn create_channel(&self, name: &str, kind: ChannelType) -> Result<Channel> {
pub fn create_channel(&self, name: &str, kind: ChannelType) -> Result<GuildChannel> {
let map = ObjectBuilder::new()
.insert("name", name)
.insert("type", kind.name())
Expand Down Expand Up @@ -1946,7 +1946,7 @@ impl PartialGuild {
/// [`rest::create_channel`]: ../client/rest/fn.create_channel.html
/// [Manage Channels]: permissions/constant.MANAGE_CHANNELS.html
#[inline]
pub fn create_channel(&self, name: &str, kind: ChannelType) -> Result<Channel> {
pub fn create_channel(&self, name: &str, kind: ChannelType) -> Result<GuildChannel> {
self.id.create_channel(name, kind)
}

Expand Down

0 comments on commit 5918d01

Please sign in to comment.