Changed functions that return a constant value into properties.

This commit is contained in:
Rapptz 2015-12-13 20:05:58 -05:00
parent c52e552888
commit ab46afee1d
3 changed files with 4 additions and 0 deletions

View File

@ -99,6 +99,7 @@ class Channel:
"""bool : Indicates if this is the default channel for the :class:`Server` it belongs to.""" """bool : Indicates if this is the default channel for the :class:`Server` it belongs to."""
return self.server.id == self.id return self.server.id == self.id
@property
def mention(self): def mention(self):
"""str : The string that allows you to mention the channel.""" """str : The string that allows you to mention the channel."""
return '<#{0.id}>'.format(self) return '<#{0.id}>'.format(self)

View File

@ -141,6 +141,7 @@ class Server:
"""Gets the default :class:`Channel` for the server.""" """Gets the default :class:`Channel` for the server."""
return utils.find(lambda c: c.is_default_channel(), self.channels) return utils.find(lambda c: c.is_default_channel(), self.channels)
@property
def icon_url(self): def icon_url(self):
"""Returns the URL version of the server's icon. Returns an empty string if it has no icon.""" """Returns the URL version of the server's icon. Returns an empty string if it has no icon."""
if self.icon is None: if self.icon is None:

View File

@ -68,6 +68,7 @@ class User(object):
return other.id != self.id return other.id != self.id
return False return False
@property
def avatar_url(self): def avatar_url(self):
"""Returns a friendly URL version of the avatar variable the user has. An empty string if """Returns a friendly URL version of the avatar variable the user has. An empty string if
the user has no avatar.""" the user has no avatar."""
@ -75,6 +76,7 @@ class User(object):
return '' return ''
return 'https://discordapp.com/api/users/{0.id}/avatars/{0.avatar}.jpg'.format(self) return 'https://discordapp.com/api/users/{0.id}/avatars/{0.avatar}.jpg'.format(self)
@property
def mention(self): def mention(self):
"""Returns a string that allows you to mention the given user.""" """Returns a string that allows you to mention the given user."""
return '<@{0.id}>'.format(self) return '<@{0.id}>'.format(self)