Browse Source

Add back __repr__ that were deleted in the Asset redesign

The Asset PR (be227ebcf0) changed some namedtuple-deriving
classes to object-deriving classes, which meant that the free __repr__ provided by namedtuple
was removed
pull/2161/head
Benjamin Mintz 6 years ago
committed by Rapptz
parent
commit
a62641bd65
  1. 4
      discord/appinfo.py
  2. 3
      discord/emoji.py
  3. 4
      discord/invite.py

4
discord/appinfo.py

@ -68,6 +68,10 @@ class AppInfo:
self.bot_require_code_grant = data['bot_require_code_grant'] self.bot_require_code_grant = data['bot_require_code_grant']
self.owner = User(state=self._state, data=data['owner']) self.owner = User(state=self._state, data=data['owner'])
def __repr__(self):
return '<{0.__class__.__name__} id={0.id} name={0.name!r} description={0.description!r} public={0.bot_public} ' \
'owner={0.owner!r}>'.format(self)
@property @property
def icon_url(self): def icon_url(self):
""":class:`.Asset`: Retrieves the application's icon asset.""" """:class:`.Asset`: Retrieves the application's icon asset."""

3
discord/emoji.py

@ -86,6 +86,9 @@ class PartialEmoji:
return '<a:%s:%s>' % (self.name, self.id) return '<a:%s:%s>' % (self.name, self.id)
return '<:%s:%s>' % (self.name, self.id) return '<:%s:%s>' % (self.name, self.id)
def __repr__(self):
return '<{0.__class__.__name__} animated={0.animated} name={0.name!r} id={0.id}>'.format(self)
def __eq__(self, other): def __eq__(self, other):
if self.is_unicode_emoji(): if self.is_unicode_emoji():
return isinstance(other, PartialEmoji) and self.name == other.name return isinstance(other, PartialEmoji) and self.name == other.name

4
discord/invite.py

@ -140,6 +140,10 @@ class PartialInviteGuild:
def __str__(self): def __str__(self):
return self.name return self.name
def __repr__(self):
return '<{0.__class__.__name__} id={0.id} name={0.name!r} features={0.features} ' \
'description={0.description!r}>'.format(self)
@property @property
def created_at(self): def created_at(self):
"""Returns the guild's creation time in UTC.""" """Returns the guild's creation time in UTC."""

Loading…
Cancel
Save