aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-08-23 02:53:56 -0400
committerRapptz <[email protected]>2015-08-23 02:53:56 -0400
commit3346b28feee0f5900080ad026b369673e6f3c6a9 (patch)
tree53ccbff2485a2caad386503a56fe66b6f49617ff /discord
parentSandbox events so exceptions being thrown don't break the client. (diff)
downloaddiscord.py-3346b28feee0f5900080ad026b369673e6f3c6a9.tar.xz
discord.py-3346b28feee0f5900080ad026b369673e6f3c6a9.zip
Add on_channel_delete event.
Diffstat (limited to 'discord')
-rw-r--r--discord/client.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/discord/client.py b/discord/client.py
index e31c04f5..ca5bd80d 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -96,6 +96,8 @@ class Client(object):
'on_message_delete': _null_event,
'on_message_edit': _null_event,
'on_status': _null_event,
+ 'on_channel_delete': _null_event,
+ 'on_channel_creation': _null_event,
}
self.ws = WebSocketClient(endpoints.WEBSOCKET_HUB, protocols=['http-only', 'chat'])
@@ -204,6 +206,14 @@ class Client(object):
self._invoke_event('on_status', server, user, status, data.get('game_id'))
elif event == 'USER_UPDATE':
self.user = User(**data)
+ elif event == 'CHANNEL_DELETE':
+ guild_id = data.get('guild_id')
+ server = next((s for s in self.servers if s.id == guild_id), None)
+ if server is not None:
+ channel_id = data.get('id')
+ channel = next((c for c in server.channels if c.id == channel_id), None)
+ server.channels.remove(channel)
+ self._invoke_event('on_channel_delete', channel)