aboutsummaryrefslogtreecommitdiff
path: root/discord/channel.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2016-12-30 04:34:42 -0500
committerRapptz <[email protected]>2017-01-03 09:52:06 -0500
commitdceba9d962483a0f423e53d472e18c8cd84c0759 (patch)
treed39c4906807eb0d2ec55070715f237b82ecc12d2 /discord/channel.py
parentFix handling of author update and missing type attribute in Message. (diff)
downloaddiscord.py-dceba9d962483a0f423e53d472e18c8cd84c0759.tar.xz
discord.py-dceba9d962483a0f423e53d472e18c8cd84c0759.zip
Add useful repr to all data classes.
Diffstat (limited to 'discord/channel.py')
-rw-r--r--discord/channel.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/discord/channel.py b/discord/channel.py
index 78a06473..75d801ef 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -341,6 +341,9 @@ class TextChannel(discord.abc.MessageChannel, CommonGuildChannel):
self.id = int(data['id'])
self._update(guild, data)
+ def __repr__(self):
+ return '<TextChannel id={0.id} name={0.name!r} position={0.position}>'.format(self)
+
def _update(self, guild, data):
self.guild = guild
self.name = data['name']
@@ -435,6 +438,9 @@ class VoiceChannel(CommonGuildChannel):
self._update(guild, data)
self.voice_members = []
+ def __repr__(self):
+ return '<VoiceChannel id={0.id} name={0.name!r} position={0.position}>'.format(self)
+
def _update(self, guild, data):
self.guild = guild
self.name = data['name']
@@ -522,6 +528,9 @@ class DMChannel(discord.abc.MessageChannel, Hashable):
def __str__(self):
return 'Direct Message with %s' % self.recipient
+ def __repr__(self):
+ return '<DMChannel id={0.id} recipient={0.recipient!r}>'.format(self)
+
@property
def created_at(self):
"""Returns the direct message channel's creation time in UTC."""
@@ -620,6 +629,9 @@ class GroupChannel(discord.abc.MessageChannel, Hashable):
return ', '.join(map(lambda x: x.name, self.recipients))
+ def __repr__(self):
+ return '<GroupChannel id={0.id} name={0.name!r}>'.format(self)
+
@property
def icon_url(self):
"""Returns the channel's icon URL if available or an empty string otherwise."""