From dceba9d962483a0f423e53d472e18c8cd84c0759 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Fri, 30 Dec 2016 04:34:42 -0500 Subject: Add useful repr to all data classes. --- discord/channel.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'discord/channel.py') 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 ''.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 ''.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 ''.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 ''.format(self) + @property def icon_url(self): """Returns the channel's icon URL if available or an empty string otherwise.""" -- cgit v1.2.3