aboutsummaryrefslogtreecommitdiff
path: root/discord/channel.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2019-05-26 02:28:49 -0400
committerRapptz <[email protected]>2019-05-26 02:32:47 -0400
commit2cd6d771eceebfa8aeb641ebd5abb454d8b52d3e (patch)
tree9312a08ca2d261c1a547b240e8e4c94a31b7769e /discord/channel.py
parentAdd note for Message.tts (diff)
downloaddiscord.py-2cd6d771eceebfa8aeb641ebd5abb454d8b52d3e.tar.xz
discord.py-2cd6d771eceebfa8aeb641ebd5abb454d8b52d3e.zip
Make __repr__ slightly more detailed and add a few missing ones.
This includes raw events (which didn't have any) and a few other types that were missing them. Upon review some more useful fields were added to the repr output which would be more useful during debugging.
Diffstat (limited to 'discord/channel.py')
-rw-r--r--discord/channel.py26
1 files changed, 21 insertions, 5 deletions
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