mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-02 00:00:02 +00:00
Add on_socket_event_type event
This commit is contained in:
parent
2cb5ce981e
commit
e2250d402e
@ -423,7 +423,9 @@ class DiscordWebSocket:
|
|||||||
msg = utils.from_json(msg)
|
msg = utils.from_json(msg)
|
||||||
|
|
||||||
log.debug('For Shard ID %s: WebSocket Event: %s', self.shard_id, msg)
|
log.debug('For Shard ID %s: WebSocket Event: %s', self.shard_id, msg)
|
||||||
self._dispatch('socket_response', msg)
|
event = msg.get('t')
|
||||||
|
if event:
|
||||||
|
self._dispatch('socket_event_type', event)
|
||||||
|
|
||||||
op = msg.get('op')
|
op = msg.get('op')
|
||||||
data = msg.get('d')
|
data = msg.get('d')
|
||||||
@ -476,8 +478,6 @@ class DiscordWebSocket:
|
|||||||
log.warning('Unknown OP code %s.', op)
|
log.warning('Unknown OP code %s.', op)
|
||||||
return
|
return
|
||||||
|
|
||||||
event = msg.get('t')
|
|
||||||
|
|
||||||
if event == 'READY':
|
if event == 'READY':
|
||||||
self._trace = trace = data.get('_trace', [])
|
self._trace = trace = data.get('_trace', [])
|
||||||
self.sequence = msg['s']
|
self.sequence = msg['s']
|
||||||
|
12
docs/api.rst
12
docs/api.rst
@ -297,6 +297,18 @@ to handle it, which defaults to print a traceback and ignoring the exception.
|
|||||||
:param kwargs: The keyword arguments for the event that raised the
|
:param kwargs: The keyword arguments for the event that raised the
|
||||||
exception.
|
exception.
|
||||||
|
|
||||||
|
.. function:: on_socket_event_type(event_type)
|
||||||
|
|
||||||
|
Called whenever a websocket event is received from the WebSocket.
|
||||||
|
|
||||||
|
This is mainly useful for logging how many events you are receiving
|
||||||
|
from the Discord gateway.
|
||||||
|
|
||||||
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
|
:param event_type: The event type from Discord that is received, e.g. ``'READY'``.
|
||||||
|
:type event_type: :class:`str`
|
||||||
|
|
||||||
.. function:: on_socket_raw_receive(msg)
|
.. function:: on_socket_raw_receive(msg)
|
||||||
|
|
||||||
Called whenever a message is received from the WebSocket, before
|
Called whenever a message is received from the WebSocket, before
|
||||||
|
Loading…
x
Reference in New Issue
Block a user