diff options
| author | khazhyk <[email protected]> | 2017-07-22 17:30:09 -0700 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-07-25 06:09:40 -0400 |
| commit | 12ca0d9b167cc55299e276f756a4f9ed8c9e921f (patch) | |
| tree | 5248e2ca8c01fe9ebb28f53e34f43453d68c6e2c /discord/utils.py | |
| parent | accept_invite() doesn't exist on rewrite (diff) | |
| download | discord.py-12ca0d9b167cc55299e276f756a4f9ed8c9e921f.tar.xz discord.py-12ca0d9b167cc55299e276f756a4f9ed8c9e921f.zip | |
avatar_url_as improvements
static_format will only apply to static (not animated) avatars. Makes
it easier to grab gif-or-'format' of an avatar. Defaults to 'webp'
This is for a similar usecase to avatar_url_as(format=None), except
one can specify the non-animated format, instead of always using
webp.
add User.avatar_is_animated property.
add validation for avatar_url_as, since invalid arguments result in
a url which will return 415, which can be confusing for a user. (They
just see a blank page)
Discord accepts size=16-2048, but images cap at 1024px, so accept 16-1024
Discord accepts "jpg", "jpeg", "png", "gif", and "webp", *unless* the
avatar is not animated, in which case "gif" is not supported. :\
Diffstat (limited to 'discord/utils.py')
| -rw-r--r-- | discord/utils.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/discord/utils.py b/discord/utils.py index 06aa5a35..d7b04503 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -281,3 +281,7 @@ def sane_wait_for(futures, *, timeout, loop): if len(pending) != 0: raise asyncio.TimeoutError() + +def valid_icon_size(size): + """Icons must be power of 2 within [16, 1024].""" + return ((size != 0) and not (size & (size - 1))) and size in range(16, 1025) |