Browse Source

Handle GUILD_ROLE_DELETE websocket events.

pull/24/head
Rapptz 10 years ago
parent
commit
16a20e5f2f
  1. 10
      discord/client.py
  2. 7
      docs/api.rst

10
discord/client.py

@ -114,7 +114,7 @@ class WebSocket(WebSocketBaseClient):
'CHANNEL_DELETE', 'CHANNEL_UPDATE', 'CHANNEL_CREATE',
'GUILD_MEMBER_ADD', 'GUILD_MEMBER_REMOVE',
'GUILD_MEMBER_UPDATE', 'GUILD_CREATE', 'GUILD_DELETE',
'GUILD_ROLE_CREATE'):
'GUILD_ROLE_CREATE', 'GUILD_ROLE_DELETE'):
self.dispatch('socket_update', event, data)
else:
@ -315,6 +315,14 @@ class ConnectionState(object):
server.roles.append(role)
self.dispatch('server_role_create', server, role)
def handle_guild_role_delete(self, data):
server = self._get_server(data.get('guild_id'))
if server is not None:
role_id = data.get('role_id')
role = utils.find(lambda r: r.id == role_id, server.roles)
server.roles.remove(role)
self.dispatch('server_role_delete', server, role)
def get_channel(self, id):
if id is None:
return None

7
docs/api.rst

@ -161,11 +161,12 @@ to handle it, which defaults to log a traceback and ignore the exception.
:param server: The :class:`Server` that got created or deleted.
.. function:: on_server_role_create(server, role)
on_server_role_delete(server, role)
Called when a :class:`Server` creates a new :class:`Role`.
Called when a :class:`Server` creates or deletes a new :class:`Role`.
:param server: The :class:`Server` that was created.
:param role: The :class:`Role` that was created.
:param server: The :class:`Server` that was created or deleted.
:param role: The :class:`Role` that was created or deleted.
Utility Functions

Loading…
Cancel
Save