Add default avatar property to User.
This commit is contained in:
@ -25,6 +25,7 @@ DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
from .utils import snowflake_time
|
||||
from .enums import DefaultAvatar
|
||||
|
||||
class User:
|
||||
"""Represents a Discord user.
|
||||
@ -83,6 +84,16 @@ class User:
|
||||
return ''
|
||||
return 'https://discordapp.com/api/users/{0.id}/avatars/{0.avatar}.jpg'.format(self)
|
||||
|
||||
@property
|
||||
def default_avatar(self):
|
||||
"""Returns the default avatar for a given user. This is calculated by the user's descriminator"""
|
||||
return DefaultAvatar(int(self.discriminator) % len(DefaultAvatar))
|
||||
|
||||
@property
|
||||
def default_avatar_url(self):
|
||||
"""Returns a URL for a user's default avatar."""
|
||||
return 'https://discordapp.com/assets/{0.url}.png'.format(self.default_avatar)
|
||||
|
||||
@property
|
||||
def mention(self):
|
||||
"""Returns a string that allows you to mention the given user."""
|
||||
|
Reference in New Issue
Block a user