aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/activity.py12
-rw-r--r--discord/audit_logs.py6
-rw-r--r--discord/channel.py26
-rw-r--r--discord/emoji.py2
-rw-r--r--discord/guild.py7
-rw-r--r--discord/invite.py4
-rw-r--r--discord/message.py5
-rw-r--r--discord/object.py3
-rw-r--r--discord/raw_models.py15
9 files changed, 65 insertions, 15 deletions
diff --git a/discord/activity.py b/discord/activity.py
index fd940209..692e20e9 100644
--- a/discord/activity.py
+++ b/discord/activity.py
@@ -152,6 +152,18 @@ class Activity(_ActivityTag):
self.session_id = kwargs.pop('session_id', None)
self.type = try_enum(ActivityType, kwargs.pop('type', -1))
+ def __repr__(self):
+ attrs = (
+ 'type',
+ 'name',
+ 'url',
+ 'details',
+ 'application_id',
+ 'session_id',
+ )
+ mapped = ' '.join('%s=%r' % (attr, getattr(self, attr)) for attr in attrs)
+ return '<Activity %s>' % mapped
+
def to_dict(self):
ret = {}
for attr in self.__slots__:
diff --git a/discord/audit_logs.py b/discord/audit_logs.py
index 49a5bb5a..0a1fe101 100644
--- a/discord/audit_logs.py
+++ b/discord/audit_logs.py
@@ -93,7 +93,8 @@ class AuditLogDiff:
return iter(self.__dict__.items())
def __repr__(self):
- return '<AuditLogDiff attrs={0!r}>'.format(tuple(self.__dict__))
+ values = ' '.join('%s=%r' % item for item in self.__dict__.items())
+ return '<AuditLogDiff %s>' % values
class AuditLogChanges:
TRANSFORMERS = {
@@ -164,6 +165,9 @@ class AuditLogChanges:
self.after.color = self.after.colour
self.before.color = self.before.colour
+ def __repr__(self):
+ return '<AuditLogChanges before=%r after=%r>' % (self.before, self.after)
+
def _handle_role(self, first, second, entry, elem):
if not hasattr(first, 'roles'):
setattr(first, 'roles', [])
diff --git a/discord/channel.py b/discord/channel.py
index 1fc10224..52bc8765 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -107,7 +107,15 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
self._update(guild, data)
def __repr__(self):
- return '<TextChannel id={0.id} name={0.name!r} position={0.position}>'.format(self)
+ attrs = [
+ ('id', self.id),
+ ('name', self.name),
+ ('position', self.position),
+ ('nsfw', self.nsfw),
+ ('news', self.is_news()),
+ ('category_id', self.category_id)
+ ]
+ return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs))
def _update(self, guild, data):
self.guild = guild
@@ -491,7 +499,15 @@ class VoiceChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
self._update(guild, data)
def __repr__(self):
- return '<VoiceChannel id={0.id} name={0.name!r} position={0.position}>'.format(self)
+ attrs = [
+ ('id', self.id),
+ ('name', self.name),
+ ('position', self.position),
+ ('bitrate', self.bitrate),
+ ('user_limit', self.user_limit),
+ ('category_id', self.category_id)
+ ]
+ return '<%s %s>' % (self.__class__.__name__, ' '.join('%s=%r' % t for t in attrs))
def _get_voice_client_key(self):
return self.guild.id, 'guild_id'
@@ -629,7 +645,7 @@ class CategoryChannel(discord.abc.GuildChannel, Hashable):
self._update(guild, data)
def __repr__(self):
- return '<CategoryChannel id={0.id} name={0.name!r} position={0.position}>'.format(self)
+ return '<CategoryChannel id={0.id} name={0.name!r} position={0.position} nsfw={0.nsfw}>'.format(self)
def _update(self, guild, data):
self.guild = guild
@@ -788,7 +804,7 @@ class StoreChannel(discord.abc.GuildChannel, Hashable):
self._update(guild, data)
def __repr__(self):
- return '<StoreChannel id={0.id} name={0.name!r} position={0.position}>'.format(self)
+ return '<StoreChannel id={0.id} name={0.name!r} position={0.position} nsfw={0.nsfw}>'.format(self)
def _update(self, guild, data):
self.guild = guild
@@ -1030,7 +1046,7 @@ class GroupChannel(discord.abc.Messageable, Hashable):
@property
def icon_url(self):
- """:class:`Asset`: Returns the channel's icon asset."""
+ """:class:`Asset`: Returns the channel's icon asset if available."""
return Asset._from_icon(self._state, self, 'channel')
@property
diff --git a/discord/emoji.py b/discord/emoji.py
index bad4a4fc..2ab349f7 100644
--- a/discord/emoji.py
+++ b/discord/emoji.py
@@ -206,7 +206,7 @@ class Emoji:
return "<:{0.name}:{0.id}>".format(self)
def __repr__(self):
- return '<Emoji id={0.id} name={0.name!r}>'.format(self)
+ return '<Emoji id={0.id} name={0.name!r} animated={0.animated} managed={0.managed}>'.format(self)
def __eq__(self, other):
return isinstance(other, (PartialEmoji, Emoji)) and self.id == other.id
diff --git a/discord/guild.py b/discord/guild.py
index 2a6226aa..12de00b7 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -160,7 +160,12 @@ class Guild(Hashable):
return self.name
def __repr__(self):
- return '<Guild id={0.id} name={0.name!r} chunked={0.chunked}>'.format(self)
+ attrs = (
+ 'id', 'name', 'shard_id', 'chunked'
+ )
+ resolved = ['%s=%r' % (attr, getattr(self, attr)) for attr in attrs]
+ resolved.append('member_count=%r' % getattr(self, '_member_count', None))
+ return '<Guild %s>' % ' '.join(resolved)
def _update_voice_state(self, data, channel_id):
user_id = int(data['user_id'])
diff --git a/discord/invite.py b/discord/invite.py
index bf1124f6..b487162c 100644
--- a/discord/invite.py
+++ b/discord/invite.py
@@ -294,7 +294,9 @@ class Invite(Hashable):
return self.url
def __repr__(self):
- return '<Invite code={0.code!r}>'.format(self)
+ return '<Invite code={0.code!r} guild={0.guild!r} ' \
+ 'online={0.approximate_presence_count} ' \
+ 'members={0.approximate_member_count}>'.format(self)
def __hash__(self):
return hash(self.code)
diff --git a/discord/message.py b/discord/message.py
index 8bbf539c..5ed97d59 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -78,6 +78,9 @@ class Attachment:
""":class:`bool`: Whether this attachment contains a spoiler."""
return self.filename.startswith('SPOILER_')
+ def __repr__(self):
+ return '<Attachment id={0.id} filename={0.filename!r} url={0.url!r}>'.format(self)
+
async def save(self, fp, *, seek_begin=True, use_cached=False):
"""|coro|
@@ -263,7 +266,7 @@ class Message:
self._update(channel, data)
def __repr__(self):
- return '<Message id={0.id} pinned={0.pinned} author={0.author!r}>'.format(self)
+ return '<Message id={0.id} channel={0.channel!r} type={0.type!r} author={0.author!r}>'.format(self)
def _try_patch(self, data, key, transform=None):
try:
diff --git a/discord/object.py b/discord/object.py
index ea4fac98..ef2a98cf 100644
--- a/discord/object.py
+++ b/discord/object.py
@@ -64,6 +64,9 @@ class Object(Hashable):
def __init__(self, id):
self.id = id
+ def __repr__(self):
+ return '<Object id=%r>' % self.id
+
@property
def created_at(self):
"""Returns the snowflake's creation time in UTC."""
diff --git a/discord/raw_models.py b/discord/raw_models.py
index 72de4450..d4e9c58e 100644
--- a/discord/raw_models.py
+++ b/discord/raw_models.py
@@ -24,7 +24,12 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
-class RawMessageDeleteEvent:
+class _RawReprMixin:
+ def __repr__(self):
+ value = ' '.join('%s=%r' % (attr, getattr(self, attr)) for attr in self.__slots__)
+ return '<%s %s>' % (self.__class__.__name__, value)
+
+class RawMessageDeleteEvent(_RawReprMixin):
"""Represents the event payload for a :func:`on_raw_message_delete` event.
Attributes
@@ -50,7 +55,7 @@ class RawMessageDeleteEvent:
except KeyError:
self.guild_id = None
-class RawBulkMessageDeleteEvent:
+class RawBulkMessageDeleteEvent(_RawReprMixin):
"""Represents the event payload for a :func:`on_raw_bulk_message_delete` event.
Attributes
@@ -77,7 +82,7 @@ class RawBulkMessageDeleteEvent:
except KeyError:
self.guild_id = None
-class RawMessageUpdateEvent:
+class RawMessageUpdateEvent(_RawReprMixin):
"""Represents the payload for a :func:`on_raw_message_edit` event.
Attributes
@@ -98,7 +103,7 @@ class RawMessageUpdateEvent:
self.data = data
self.cached_message = None
-class RawReactionActionEvent:
+class RawReactionActionEvent(_RawReprMixin):
"""Represents the payload for a :func:`on_raw_reaction_add` or
:func:`on_raw_reaction_remove` event.
@@ -129,7 +134,7 @@ class RawReactionActionEvent:
except KeyError:
self.guild_id = None
-class RawReactionClearEvent:
+class RawReactionClearEvent(_RawReprMixin):
"""Represents the payload for a :func:`on_raw_reaction_clear` event.
Attributes