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,10 +26,23 @@ DEALINGS IN THE SOFTWARE.
from .permissions import Permissions
from .colour import Colour
from .mixins import EqualityComparable
class Role(object):
class Role(EqualityComparable):
"""Represents a Discord role in a :class:`Server`.
Supported Operations:
+-----------+------------------------------------+
| Operation | Description |
+===========+====================================+
| x == y | Checks if two roles are equal. |
+-----------+------------------------------------+
| x != y | Checks if two roles are not equal. |
+-----------+------------------------------------+
| str(x) | Returns the role's name. |
+-----------+------------------------------------+
Attributes
----------
id : str
@ -53,6 +66,9 @@ class Role(object):
self._is_everyone = kwargs.get('everyone', False)
self.update(**kwargs)
def __str__(self):
return self.name
def update(self, **kwargs):
self.id = kwargs.get('id')
self.name = kwargs.get('name')