Skip to content

Commit

Permalink
defer to delete_message if there's just one message to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
arqunis committed Oct 16, 2017
1 parent 5829c67 commit c7aa27d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/model/channel/channel_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ impl ChannelId {
.into_iter()
.map(|message_id| message_id.as_ref().0)
.collect::<Vec<u64>>();

if ids.len() == 1 {
self.delete_message(ids[0])
} else {
let map = json!({ "messages": ids });

let map = json!({ "messages": ids });

http::delete_messages(self.0, &map)
http::delete_messages(self.0, &map)
}
}

/// Deletes all permission overrides in the channel from a member or role.
Expand Down
2 changes: 1 addition & 1 deletion src/model/channel/guild_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl GuildChannel {
/// [`Channel::delete_messages`]: enum.Channel.html#method.delete_messages
/// [Manage Messages]: permissions/constant.MANAGE_MESSAGES.html
#[inline]
pub fn delete_messages<'a, It: IntoIterator<Item=&'a MessageId>>(&self, message_ids: It) -> Result<()> {
pub fn delete_messages<T: AsRef<MessageId>, It: IntoIterator<Item=T>>(&self, message_ids: It) -> Result<()> {
self.id.delete_messages(message_ids)
}

Expand Down

0 comments on commit c7aa27d

Please sign in to comment.