aboutsummaryrefslogtreecommitdiff
path: root/discord/channel.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-12-13 22:53:48 -0500
committerRapptz <[email protected]>2015-12-13 22:53:48 -0500
commit9137d92f67a6d50782e199ca6d6558c1ea6015e2 (patch)
treed900865b68c18ad1712de4d6d6914f93c43bb7bf /discord/channel.py
parentChanged functions that return a constant value into properties. (diff)
downloaddiscord.py-9137d92f67a6d50782e199ca6d6558c1ea6015e2.tar.xz
discord.py-9137d92f67a6d50782e199ca6d6558c1ea6015e2.zip
All data classes now support !=, == and str(obj).
Diffstat (limited to 'discord/channel.py')
-rw-r--r--discord/channel.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/discord/channel.py b/discord/channel.py
index edb45817..41445a12 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -28,12 +28,25 @@ from . import utils
from .permissions import Permissions
from .enums import ChannelType
from collections import namedtuple
+from .mixins import EqualityComparable
Overwrites = namedtuple('Overwrites', 'id allow deny type')
-class Channel:
+class Channel(EqualityComparable):
"""Represents a Discord server channel.
+ Supported Operations:
+
+ +-----------+---------------------------------------+
+ | Operation | Description |
+ +===========+=======================================+
+ | x == y | Checks if two channels are equal. |
+ +-----------+---------------------------------------+
+ | x != y | Checks if two channels are not equal. |
+ +-----------+---------------------------------------+
+ | str(x) | Returns the channel's name. |
+ +-----------+---------------------------------------+
+
Attributes
-----------
name : str
@@ -63,6 +76,9 @@ class Channel:
self.update(**kwargs)
self.voice_members = []
+ def __str__(self):
+ return self.name
+
def update(self, **kwargs):
self.name = kwargs.get('name')
self.server = kwargs.get('server')
@@ -179,9 +195,21 @@ class Channel:
return base
-class PrivateChannel:
+class PrivateChannel(EqualityComparable):
"""Represents a Discord private channel.
+ Supported Operations:
+
+ +-----------+-------------------------------------------------+
+ | Operation | Description |
+ +===========+=================================================+
+ | x == y | Checks if two channels are equal. |
+ +-----------+-------------------------------------------------+
+ | x != y | Checks if two channels are not equal. |
+ +-----------+-------------------------------------------------+
+ | str(x) | Returns the string "Direct Message with <User>" |
+ +-----------+-------------------------------------------------+
+
Attributes
----------
user : :class:`User`
@@ -197,6 +225,9 @@ class PrivateChannel:
self.id = id
self.is_private = True
+ def __str__(self):
+ return 'Direct Message with {0.name}'.format(self.user)
+
def permissions_for(user):
"""Handles permission resolution for a :class:`User`.