aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-10-13 05:06:01 -0400
committerRapptz <[email protected]>2015-10-13 05:39:58 -0400
commit608384dd4f447028e8562ccca08ebe1d11a25177 (patch)
tree14437030170e0ddb9d63abcb26f5d48c5075789c
parentClient.send_message can now accept a string ID as the destination. (diff)
downloaddiscord.py-608384dd4f447028e8562ccca08ebe1d11a25177.tar.xz
discord.py-608384dd4f447028e8562ccca08ebe1d11a25177.zip
Parse role colour and other new role attributes.
New attributes include hoist, position, and of course colour. An alias is in place for British and American spellings (i.e. color).
-rw-r--r--discord/server.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/discord/server.py b/discord/server.py
index d3f48eb8..d693fd8c 100644
--- a/discord/server.py
+++ b/discord/server.py
@@ -42,12 +42,38 @@ class Role(object):
.. attribute:: permissions
A :class:`Permissions` that represents the role's permissions.
+ .. attribute:: color
+ colour
+
+ A tuple of (r, g, b) associated with the role colour.
+ .. attribute:: hoist
+
+ A boolean representing if the role will be displayed separately from other members.
+ .. attribute:: position
+
+ The position of the role.
"""
def __init__(self, **kwargs):
self.id = kwargs.get('id')
self.name = kwargs.get('name')
self.permissions = Permissions(kwargs.get('permissions', 0))
+ self.position = kwargs.get('position', -1)
+ self.colour = kwargs.get('color', 0)
+ self.hoist = kwargs.get('hoist', False)
+ self._colour_to_tuple()
+
+ def _colour_to_tuple(self):
+ # first we turn this into a hex string
+ # the reason why we're using a hex string rather than just use bitwise
+ # ops is because we don't want to care too much about endianness.
+ hex_str = format(self.colour, '06x')
+ red = int(hex_str[0] + hex_str[1], base=16)
+ green = int(hex_str[2] + hex_str[3], base=16)
+ blue = int(hex_str[4] + hex_str[5], base=16)
+ self.colour = (red, green, blue)
+ self.color = self.colour
+
class Member(User):
"""Represents a Discord member to a :class:`Server`.