diff options
| author | Austin Hellyer <[email protected]> | 2016-11-12 11:21:12 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-12 11:21:12 -0800 |
| commit | e9cdc50f68ad36d78b5fcc1c0dd6463274828eca (patch) | |
| tree | c6b0bd54bae9f18906a47fd85402faea5345a1cd /src/client/mod.rs | |
| parent | Add delete_message_reactions + register event (diff) | |
| download | serenity-e9cdc50f68ad36d78b5fcc1c0dd6463274828eca.tar.xz serenity-e9cdc50f68ad36d78b5fcc1c0dd6463274828eca.zip | |
Add a check for message content length
Before sending a request to Discord, ensure that a message's content on
non-HTTP functions and methods meets the required length. If it exceeds
the limit, then return a
`Error::Client(ClientError::MessageTooLong(u64))`, containing the number
of unicode code points exceeding the limit.
Note that directly using the HTTP methods does not impose this limit.
Diffstat (limited to 'src/client/mod.rs')
| -rw-r--r-- | src/client/mod.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/client/mod.rs b/src/client/mod.rs index 4db7a4e..0f0fa7a 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -175,6 +175,13 @@ pub enum ClientError { /// /// [`State`]: ../ext/state/struct.State.html ItemMissing, + /// Indicates that a [`Message`]s content was too long and will not + /// successfully send, as the length is over 2000 codepoints, or 4000 bytes. + /// + /// The number of bytes larger than the limit is provided. + /// + /// [`Message`]: ../model/struct.Message.html + MessageTooLong(u64), /// When attempting to use a [`Context`] helper method which requires a /// contextual [`ChannelId`], but the current context is not appropriate for /// the action. |