diff options
| author | Zeyla Hellyer <[email protected]> | 2017-04-15 22:37:49 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-04-19 14:53:32 -0700 |
| commit | e1079e9a03473f9ec67414628d5b84e7ea1b5b38 (patch) | |
| tree | c872eced06b3a1dfce04e876f1d7c381ee926f29 /src/constants.rs | |
| parent | Add a test suite for event deserialization (diff) | |
| download | serenity-e1079e9a03473f9ec67414628d5b84e7ea1b5b38.tar.xz serenity-e1079e9a03473f9ec67414628d5b84e7ea1b5b38.zip | |
Check for embed lengths on message sends
Due to the maximum length of the textual content of an embed being 4000,
this should be checked prior to message sending.
Embeds have a fairly new limit of only being 4000 character long, at
maximum. The length of these fields - where present - should be summed,
so that bad requests are not made with embeds that are too large in
text.
The fields that count as "textual" includes:
- author name
- description
- `name` and `value` of each field
- footer text
- title
If this exceeds the limit - currently at 4000 unicode codepoints - then
a `ClientError::EmbedTooLarge` will be returned, including the number
of codepoints overflowing.
Diffstat (limited to 'src/constants.rs')
| -rw-r--r-- | src/constants.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/constants.rs b/src/constants.rs index 0ec973c..de670c9 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,5 +1,5 @@ -use std::result::Result as StdResult; - +/// The maximum length of the textual size of an embed. +pub const EMBED_MAX_LENGTH: u16 = 4000; /// The gateway version used by the library. The gateway URI is retrieved via /// the REST API. pub const GATEWAY_VERSION: u8 = 6; |