Most data classes now support hashing.

This commit is contained in:
Rapptz
2015-12-17 00:30:08 -05:00
parent 613214f197
commit 51d91c2a82
8 changed files with 38 additions and 9 deletions

View File

@ -28,11 +28,11 @@ from . import utils
from .permissions import Permissions
from .enums import ChannelType
from collections import namedtuple
from .mixins import EqualityComparable
from .mixins import Hashable
Overwrites = namedtuple('Overwrites', 'id allow deny type')
class Channel(EqualityComparable):
class Channel(Hashable):
"""Represents a Discord server channel.
Supported Operations:
@ -44,6 +44,8 @@ class Channel(EqualityComparable):
+-----------+---------------------------------------+
| x != y | Checks if two channels are not equal. |
+-----------+---------------------------------------+
| hash(x) | Returns the channel's hash. |
+-----------+---------------------------------------+
| str(x) | Returns the channel's name. |
+-----------+---------------------------------------+
@ -196,7 +198,7 @@ class Channel(EqualityComparable):
return base
class PrivateChannel(EqualityComparable):
class PrivateChannel(Hashable):
"""Represents a Discord private channel.
Supported Operations:
@ -208,6 +210,8 @@ class PrivateChannel(EqualityComparable):
+-----------+-------------------------------------------------+
| x != y | Checks if two channels are not equal. |
+-----------+-------------------------------------------------+
| hash(x) | Returns the channel's hash. |
+-----------+-------------------------------------------------+
| str(x) | Returns the string "Direct Message with <User>" |
+-----------+-------------------------------------------------+