aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel/group.rs
diff options
context:
space:
mode:
authorKen Swenson <[email protected]>2017-05-28 15:56:47 -0400
committerZeyla Hellyer <[email protected]>2017-05-28 12:56:47 -0700
commit46b79ddb45d03bfbe0eb10a9d5e1c53c9a15f55b (patch)
treeaddb6c38cb0b5f81122841474deed95897e62d57 /src/model/channel/group.rs
parentimpl From<char> for ReactionType (diff)
downloadserenity-46b79ddb45d03bfbe0eb10a9d5e1c53c9a15f55b.tar.xz
serenity-46b79ddb45d03bfbe0eb10a9d5e1c53c9a15f55b.zip
Implement multiple attachments
Diffstat (limited to 'src/model/channel/group.rs')
-rw-r--r--src/model/channel/group.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs
index aab3e3a..6adedc6 100644
--- a/src/model/channel/group.rs
+++ b/src/model/channel/group.rs
@@ -7,6 +7,8 @@ use ::model::*;
use ::builder::{CreateMessage, GetMessages};
#[cfg(feature="model")]
use ::http;
+#[cfg(feature="model")]
+use ::http::AttachmentType;
/// A group channel - potentially including other [`User`]s - separate from a
/// [`Guild`].
@@ -298,11 +300,37 @@ impl Group {
/// [`ModelError::MessageTooLong`]: enum.ModelError.html#variant.MessageTooLong
/// [Attach Files]: permissions/constant.ATTACH_FILES.html
/// [Send Messages]: permissions/constant.SEND_MESSAGES.html
+ #[deprecated(since="0.2.0", note="Please use `send_files` instead.")]
+ #[allow(deprecated)]
pub fn send_file<F, R>(&self, file: R, filename: &str, f: F) -> Result<Message>
where F: FnOnce(CreateMessage) -> CreateMessage, R: Read {
self.channel_id.send_file(file, filename, f)
}
+ /// Sends (a) file(s) along with optional message contents.
+ ///
+ /// Refer to [`ChannelId::send_file`] for examples and more information.
+ ///
+ /// The [Attach Files] and [Send Messages] permissions are required.
+ ///
+ /// **Note**: Message contents must be under 2000 unicode code points.
+ ///
+ /// # Errors
+ ///
+ /// If the content of the message is over the above limit, then a
+ /// [`ClientError::MessageTooLong`] will be returned, containing the number
+ /// of unicode code points over the limit.
+ ///
+ /// [`ChannelId::send_file`]: struct.ChannelId.html#method.send_file
+ /// [`ClientError::MessageTooLong`]: ../client/enum.ClientError.html#variant.MessageTooLong
+ /// [Attach Files]: permissions/constant.ATTACH_FILES.html
+ /// [Send Messages]: permissions/constant.SEND_MESSAGES.html
+ #[inline]
+ pub fn send_files<F, T: Into<AttachmentType>>(&self, files: Vec<T>, f: F) -> Result<Message>
+ where F: FnOnce(CreateMessage) -> CreateMessage {
+ self.channel_id.send_files(files, f)
+ }
+
/// Sends a message to the group with the given content.
///
/// Refer to the documentation for [`CreateMessage`] for more information