mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Handle GUILD_ROLE_UPDATE websocket events.
This commit is contained in:
parent
16a20e5f2f
commit
4ff7d22edd
@ -114,7 +114,8 @@ class WebSocket(WebSocketBaseClient):
|
|||||||
'CHANNEL_DELETE', 'CHANNEL_UPDATE', 'CHANNEL_CREATE',
|
'CHANNEL_DELETE', 'CHANNEL_UPDATE', 'CHANNEL_CREATE',
|
||||||
'GUILD_MEMBER_ADD', 'GUILD_MEMBER_REMOVE',
|
'GUILD_MEMBER_ADD', 'GUILD_MEMBER_REMOVE',
|
||||||
'GUILD_MEMBER_UPDATE', 'GUILD_CREATE', 'GUILD_DELETE',
|
'GUILD_MEMBER_UPDATE', 'GUILD_CREATE', 'GUILD_DELETE',
|
||||||
'GUILD_ROLE_CREATE', 'GUILD_ROLE_DELETE'):
|
'GUILD_ROLE_CREATE', 'GUILD_ROLE_DELETE',
|
||||||
|
'GUILD_ROLE_UPDATE'):
|
||||||
self.dispatch('socket_update', event, data)
|
self.dispatch('socket_update', event, data)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -323,6 +324,14 @@ class ConnectionState(object):
|
|||||||
server.roles.remove(role)
|
server.roles.remove(role)
|
||||||
self.dispatch('server_role_delete', server, role)
|
self.dispatch('server_role_delete', server, role)
|
||||||
|
|
||||||
|
def handle_guild_role_update(self, data):
|
||||||
|
server = self._get_server(data.get('guild_id'))
|
||||||
|
if server is not None:
|
||||||
|
role_id = data['role']['id']
|
||||||
|
role = utils.find(lambda r: r.id == role_id, server.roles)
|
||||||
|
role.update(**data['role'])
|
||||||
|
self.dispatch('server_role_update', role)
|
||||||
|
|
||||||
def get_channel(self, id):
|
def get_channel(self, id):
|
||||||
if id is None:
|
if id is None:
|
||||||
return None
|
return None
|
||||||
|
@ -55,6 +55,9 @@ class Role(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
self.update(**kwargs)
|
||||||
|
|
||||||
|
def update(self, **kwargs):
|
||||||
self.id = kwargs.get('id')
|
self.id = kwargs.get('id')
|
||||||
self.name = kwargs.get('name')
|
self.name = kwargs.get('name')
|
||||||
self.permissions = Permissions(kwargs.get('permissions', 0))
|
self.permissions = Permissions(kwargs.get('permissions', 0))
|
||||||
|
@ -168,6 +168,12 @@ to handle it, which defaults to log a traceback and ignore the exception.
|
|||||||
:param server: The :class:`Server` that was created or deleted.
|
:param server: The :class:`Server` that was created or deleted.
|
||||||
:param role: The :class:`Role` that was created or deleted.
|
:param role: The :class:`Role` that was created or deleted.
|
||||||
|
|
||||||
|
.. function:: on_server_role_update(role)
|
||||||
|
|
||||||
|
Called when a :class:`Role` is changed server-wide.
|
||||||
|
|
||||||
|
:param role: The :class:`Role` that was updated.
|
||||||
|
|
||||||
|
|
||||||
Utility Functions
|
Utility Functions
|
||||||
-----------------
|
-----------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user