diff options
| author | Rapptz <[email protected]> | 2015-10-16 07:13:24 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2015-10-16 07:48:50 -0400 |
| commit | 411b477a02042ebec9f1a1fe944b114611c40b1b (patch) | |
| tree | d93865a9b4d1539ca03c07f46cb7f9cef9299ba6 /discord/server.py | |
| parent | Handle VOICE_STATE_UPDATE websocket events. (diff) | |
| download | discord.py-411b477a02042ebec9f1a1fe944b114611c40b1b.tar.xz discord.py-411b477a02042ebec9f1a1fe944b114611c40b1b.zip | |
Separate colour tuple into its own class.
Also enumerate all the constant colours that Discord currently
supports.
Diffstat (limited to 'discord/server.py')
| -rw-r--r-- | discord/server.py | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/discord/server.py b/discord/server.py index 8ddc9f0f..0e596d44 100644 --- a/discord/server.py +++ b/discord/server.py @@ -25,59 +25,8 @@ DEALINGS IN THE SOFTWARE. """ from .user import User -from .permissions import Permissions from .utils import parse_time -class Role(object): - """Represents a Discord role in a :class:`Server`. - - Instance attributes: - - .. attribute:: id - - The ID for the role. - .. attribute:: name - - The name of the role. - .. 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.update(**kwargs) - - def update(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`. |