Add support for guild subscriptions.

This commit is contained in:
Rapptz 2019-07-10 03:40:35 -04:00
parent 5c1b239b47
commit 7b8d50a988
3 changed files with 26 additions and 0 deletions

View File

@ -152,6 +152,30 @@ class Client:
WebSocket in the case of not receiving a HEARTBEAT_ACK. Useful if WebSocket in the case of not receiving a HEARTBEAT_ACK. Useful if
processing the initial packets take too long to the point of disconnecting processing the initial packets take too long to the point of disconnecting
you. The default timeout is 60 seconds. you. The default timeout is 60 seconds.
guild_subscriptions: :class:`bool`
Whether to dispatching of presence or typing events. Defaults to ``True``.
.. warning::
If this is set to ``False`` then the following features will be disabled:
- No user related updates (:func:`on_user_update` will not dispatch)
- No presence related changes will be recorded (e.g. :attr:`Member.activities` or :attr:`Member.status`)
- If ``fetch_offline_members`` is set to ``False`` then the user cache will not exist.
This makes it difficult or impossible to do many things, for example:
- Computing permissions
- Querying members in a voice channel via :attr:`VoiceChannel.members` will be empty.
- Most forms of receiving :class:`Member` will be
receiving :class:`User` instead, except for message events.
- :attr:`Guild.owner` will usually resolve to ``None``.
- :meth:`Guild.get_member` will usually be unavailable.
- Anything that involves using :class:`Member`.
- :attr:`users` will not be as populated.
- etc.
In short, this makes it so the only member you can reliably query is the
message author. Useful for bots that do not require any state.
Attributes Attributes
----------- -----------

View File

@ -297,6 +297,7 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
}, },
'compress': True, 'compress': True,
'large_threshold': 250, 'large_threshold': 250,
'guild_subscriptions': self._connection.guild_subscriptions,
'v': 3 'v': 3
} }
} }

View File

@ -70,6 +70,7 @@ class ConnectionState:
self._ready_task = None self._ready_task = None
self._fetch_offline = options.get('fetch_offline_members', True) self._fetch_offline = options.get('fetch_offline_members', True)
self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0) self.heartbeat_timeout = options.get('heartbeat_timeout', 60.0)
self.guild_subscriptions = options.get('guild_subscriptions', True)
self._listeners = [] self._listeners = []
activity = options.get('activity', None) activity = options.get('activity', None)