1919
2020from aiohttp import WSMessage
2121
22- from ..api .models .gw import Presence
2322from ..base import get_logger
2423from ..enums import InteractionType , OptionType
2524from ..models .command import Option
2928from .http import HTTPClient
3029from .models .flags import Intents
3130from .models .misc import MISSING
31+ from .models .presence import ClientPresence
3232
3333log : Logger = get_logger ("gateway" )
3434
@@ -68,7 +68,7 @@ class WebSocketClient:
6868 :ivar dict _ready: The contents of the application returned when ready.
6969 :ivar _Heartbeat __heartbeater: The context state of a "heartbeat" made to the Gateway.
7070 :ivar Optional[List[Tuple[int]]] __shard: The shards used during connection.
71- :ivar Optional[Presence ] __presence: The presence used in connection.
71+ :ivar Optional[ClientPresence ] __presence: The presence used in connection.
7272 :ivar Task __task: The closing task for ending connections.
7373 :ivar int session_id: The ID of the ongoing session.
7474 :ivar str sequence: The sequence identifier of the ongoing session.
@@ -161,15 +161,17 @@ async def __restart(self):
161161 await self ._establish_connection ()
162162
163163 async def _establish_connection (
164- self , shard : Optional [List [Tuple [int ]]] = MISSING , presence : Optional [Presence ] = MISSING
164+ self ,
165+ shard : Optional [List [Tuple [int ]]] = MISSING ,
166+ presence : Optional [ClientPresence ] = MISSING ,
165167 ) -> None :
166168 """
167169 Establishes a client connection with the Gateway.
168170
169171 :param shard?: The shards to establish a connection with. Defaults to ``None``.
170172 :type shard: Optional[List[Tuple[int]]]
171173 :param presence: The presence to carry with. Defaults to ``None``.
172- :type presence: Optional[Presence ]
174+ :type presence: Optional[ClientPresence ]
173175 """
174176 self ._options ["headers" ] = {"User-Agent" : self ._http ._req ._headers ["User-Agent" ]}
175177 url = await self ._http .get_gateway ()
@@ -193,7 +195,7 @@ async def _handle_connection(
193195 self ,
194196 stream : Dict [str , Any ],
195197 shard : Optional [List [Tuple [int ]]] = MISSING ,
196- presence : Optional [Presence ] = MISSING ,
198+ presence : Optional [ClientPresence ] = MISSING ,
197199 ) -> None :
198200 """
199201 Handles the client's connection with the Gateway.
@@ -203,7 +205,7 @@ async def _handle_connection(
203205 :param shard?: The shards to establish a connection with. Defaults to ``None``.
204206 :type shard: Optional[List[Tuple[int]]]
205207 :param presence: The presence to carry with. Defaults to ``None``.
206- :type presence: Optional[Presence ]
208+ :type presence: Optional[ClientPresence ]
207209 """
208210 op : Optional [int ] = stream .get ("op" )
209211 event : Optional [str ] = stream .get ("t" )
@@ -462,15 +464,15 @@ async def _send_packet(self, data: Dict[str, Any]) -> None:
462464 log .debug (packet )
463465
464466 async def __identify (
465- self , shard : Optional [List [Tuple [int ]]] = None , presence : Optional [Presence ] = None
467+ self , shard : Optional [List [Tuple [int ]]] = None , presence : Optional [ClientPresence ] = None
466468 ) -> None :
467469 """
468470 Sends an ``IDENTIFY`` packet to the gateway.
469471
470472 :param shard?: The shard ID to identify under.
471473 :type shard: Optional[List[Tuple[int]]]
472474 :param presence?: The presence to change the bot to on identify.
473- :type presence: Optional[Presence ]
475+ :type presence: Optional[ClientPresence ]
474476 """
475477 self .__shard = shard
476478 self .__presence = presence
@@ -489,7 +491,7 @@ async def __identify(
489491
490492 if isinstance (shard , List ) and len (shard ) >= 1 :
491493 payload ["d" ]["shard" ] = shard
492- if isinstance (presence , Presence ):
494+ if isinstance (presence , ClientPresence ):
493495 payload ["d" ]["presence" ] = presence ._json
494496
495497 log .debug (f"IDENTIFYING: { payload } " )
@@ -518,6 +520,6 @@ def shard(self) -> Optional[List[Tuple[int]]]:
518520 return self .__shard
519521
520522 @property
521- def presence (self ) -> Optional [Presence ]:
523+ def presence (self ) -> Optional [ClientPresence ]:
522524 """Returns the current presence."""
523525 return self .__presence
0 commit comments