All data classes now support !=, == and str(obj).

This commit is contained in:
Rapptz
2015-12-13 22:53:48 -05:00
parent ab46afee1d
commit 9137d92f67
8 changed files with 149 additions and 17 deletions

View File

@ -26,13 +26,26 @@ DEALINGS IN THE SOFTWARE.
from .user import User
from .utils import parse_time
from .mixins import EqualityComparable
class Invite(object):
class Invite(EqualityComparable):
"""Represents a Discord :class:`Server` or :class:`Channel` invite.
Depending on the way this object was created, some of the attributes can
have a value of ``None``.
Supported Operations:
+-----------+--------------------------------------+
| Operation | Description |
+===========+======================================+
| x == y | Checks if two invites are equal. |
+-----------+--------------------------------------+
| x != y | Checks if two invites are not equal. |
+-----------+--------------------------------------+
| str(x) | Returns the invite's URL. |
+-----------+--------------------------------------+
Attributes
-----------
max_age : int
@ -75,6 +88,9 @@ class Invite(object):
self.inviter = None if inviter_data is None else User(**inviter_data)
self.channel = kwargs.get('channel')
def __str__(self):
return self.url
@property
def id(self):
"""Returns the proper code portion of the invite."""