|
61 | 61 | from .enums import Status |
62 | 62 | from .state import ConnectionState |
63 | 63 | from .types.snowflake import Snowflake |
| 64 | + from .types.gateway import BulkGuildSubscribePayload |
64 | 65 | from .voice_client import VoiceClient |
65 | 66 |
|
66 | 67 |
|
@@ -238,45 +239,10 @@ class DiscordWebSocket: |
238 | 239 |
|
239 | 240 | Attributes |
240 | 241 | ----------- |
241 | | - DISPATCH |
242 | | - Receive only. Denotes an event to be sent to Discord, such as READY. |
243 | | - HEARTBEAT |
244 | | - When received tells Discord to keep the connection alive. |
245 | | - When sent asks if your connection is currently alive. |
246 | | - IDENTIFY |
247 | | - Send only. Starts a new session. |
248 | | - PRESENCE |
249 | | - Send only. Updates your presence. |
250 | | - VOICE_STATE |
251 | | - Send only. Starts a new connection to a voice guild. |
252 | | - VOICE_PING |
253 | | - Send only. Checks ping time to a voice guild, do not use. |
254 | | - RESUME |
255 | | - Send only. Resumes an existing connection. |
256 | | - RECONNECT |
257 | | - Receive only. Tells the client to reconnect to a new gateway. |
258 | | - REQUEST_MEMBERS |
259 | | - Send only. Asks for the guild members. |
260 | | - INVALIDATE_SESSION |
261 | | - Receive only. Tells the client to optionally invalidate the session |
262 | | - and IDENTIFY again. |
263 | | - HELLO |
264 | | - Receive only. Tells the client the heartbeat interval. |
265 | | - HEARTBEAT_ACK |
266 | | - Receive only. Confirms receiving of a heartbeat. Not having it implies |
267 | | - a connection issue. |
268 | | - GUILD_SYNC |
269 | | - Send only. Requests a guild sync. This is unfortunately no longer functional. |
270 | | - CALL_CONNECT |
271 | | - Send only. Maybe used for calling? Probably just tracking. |
272 | | - GUILD_SUBSCRIBE |
273 | | - Send only. Subscribes you to guilds/guild members. Might respond with GUILD_MEMBER_LIST_UPDATE. |
274 | | - REQUEST_COMMANDS |
275 | | - Send only. Requests application commands from a guild. Responds with GUILD_APPLICATION_COMMANDS_UPDATE. |
276 | 242 | gateway |
277 | 243 | The gateway we are currently connected to. |
278 | 244 | token |
279 | | - The authentication token for discord. |
| 245 | + The authentication token for Discord. |
280 | 246 | """ |
281 | 247 |
|
282 | 248 | if TYPE_CHECKING: |
@@ -307,11 +273,12 @@ class DiscordWebSocket: |
307 | 273 | INVALIDATE_SESSION = 9 |
308 | 274 | HELLO = 10 |
309 | 275 | HEARTBEAT_ACK = 11 |
310 | | - GUILD_SYNC = 12 # :( |
| 276 | + # GUILD_SYNC = 12 |
311 | 277 | CALL_CONNECT = 13 |
312 | | - GUILD_SUBSCRIBE = 14 |
313 | | - REQUEST_COMMANDS = 24 |
| 278 | + GUILD_SUBSCRIBE = 14 # Deprecated |
| 279 | + # REQUEST_COMMANDS = 24 |
314 | 280 | SEARCH_RECENT_MEMBERS = 35 |
| 281 | + BULK_GUILD_SUBSCRIBE = 37 |
315 | 282 | # fmt: on |
316 | 283 |
|
317 | 284 | def __init__(self, socket: aiohttp.ClientWebSocketResponse, *, loop: asyncio.AbstractEventLoop) -> None: |
@@ -727,7 +694,7 @@ async def change_presence( |
727 | 694 | self.afk = afk |
728 | 695 | self.idle_since = since |
729 | 696 |
|
730 | | - async def request_lazy_guild( |
| 697 | + async def guild_subscribe( |
731 | 698 | self, |
732 | 699 | guild_id: Snowflake, |
733 | 700 | *, |
@@ -762,6 +729,17 @@ async def request_lazy_guild( |
762 | 729 | _log.debug('Subscribing to guild %s with payload %s', guild_id, payload['d']) |
763 | 730 | await self.send_as_json(payload) |
764 | 731 |
|
| 732 | + async def bulk_guild_subscribe(self, subscriptions: BulkGuildSubscribePayload) -> None: |
| 733 | + payload = { |
| 734 | + 'op': self.BULK_GUILD_SUBSCRIBE, |
| 735 | + 'd': { |
| 736 | + 'subscriptions': subscriptions, |
| 737 | + }, |
| 738 | + } |
| 739 | + |
| 740 | + _log.debug('Subscribing to guilds with payload %s', payload['d']) |
| 741 | + await self.send_as_json(payload) |
| 742 | + |
765 | 743 | async def request_chunks( |
766 | 744 | self, |
767 | 745 | guild_ids: List[Snowflake], |
@@ -821,44 +799,6 @@ async def call_connect(self, channel_id: Snowflake): |
821 | 799 | _log.debug('Requesting call connect for channel %s.', channel_id) |
822 | 800 | await self.send_as_json(payload) |
823 | 801 |
|
824 | | - async def request_commands( |
825 | | - self, |
826 | | - guild_id: Snowflake, |
827 | | - type: int, |
828 | | - *, |
829 | | - nonce: Optional[str] = None, |
830 | | - limit: Optional[int] = None, |
831 | | - applications: Optional[bool] = None, |
832 | | - offset: int = 0, |
833 | | - query: Optional[str] = None, |
834 | | - command_ids: Optional[List[Snowflake]] = None, |
835 | | - application_id: Optional[Snowflake] = None, |
836 | | - ) -> None: |
837 | | - payload = { |
838 | | - 'op': self.REQUEST_COMMANDS, |
839 | | - 'd': { |
840 | | - 'guild_id': str(guild_id), |
841 | | - 'type': type, |
842 | | - }, |
843 | | - } |
844 | | - |
845 | | - if nonce is not None: |
846 | | - payload['d']['nonce'] = nonce |
847 | | - if applications is not None: |
848 | | - payload['d']['applications'] = applications |
849 | | - if limit is not None and limit != 25: |
850 | | - payload['d']['limit'] = limit |
851 | | - if offset: |
852 | | - payload['d']['offset'] = offset |
853 | | - if query is not None: |
854 | | - payload['d']['query'] = query |
855 | | - if command_ids is not None: |
856 | | - payload['d']['command_ids'] = command_ids |
857 | | - if application_id is not None: |
858 | | - payload['d']['application_id'] = str(application_id) |
859 | | - |
860 | | - await self.send_as_json(payload) |
861 | | - |
862 | 802 | async def search_recent_members( |
863 | 803 | self, guild_id: Snowflake, query: str = '', *, after: Optional[Snowflake] = None, nonce: Optional[str] = None |
864 | 804 | ) -> None: |
|
0 commit comments