mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 04:19:31 +02:00
Add support for animated avatars
This commit is contained in:
@@ -15,6 +15,7 @@ DEFAULT_SCOPES = [
|
|||||||
|
|
||||||
|
|
||||||
IMAGE_BASE_URL = "https://cdn.discordapp.com/"
|
IMAGE_BASE_URL = "https://cdn.discordapp.com/"
|
||||||
|
IMAGE_FORMAT = "png"
|
||||||
USER_AVATAR_BASE_URL = IMAGE_BASE_URL + "avatars/{user_id}/{avatar_hash}.png"
|
ANIMATED_IMAGE_FORMAT = "gif"
|
||||||
|
USER_AVATAR_BASE_URL = IMAGE_BASE_URL + "avatars/{user_id}/{avatar_hash}.{format}"
|
||||||
GUILD_ICON_BASE_URL = IMAGE_BASE_URL + "icons/{guild_id}/{icon_hash}.png"
|
GUILD_ICON_BASE_URL = IMAGE_BASE_URL + "icons/{guild_id}/{icon_hash}.png"
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ class User(DiscordModelsBase):
|
|||||||
@property
|
@property
|
||||||
def avatar_url(self):
|
def avatar_url(self):
|
||||||
"""A property returning direct URL to user's avatar."""
|
"""A property returning direct URL to user's avatar."""
|
||||||
return configs.USER_AVATAR_BASE_URL.format(user_id=self.id, avatar_hash=self.avatar_hash)
|
image_format = configs.ANIMATED_IMAGE_FORMAT if self.is_avatar_animated else configs.IMAGE_FORMAT
|
||||||
|
return configs.USER_AVATAR_BASE_URL.format(user_id=self.id, avatar_hash=self.avatar_hash, format=image_format)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_avatar_animated(self):
|
def is_avatar_animated(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user