@@ -373,7 +373,7 @@ class GatewayShardImpl(shard.GatewayShard):
373373 ----------
374374 token : str
375375 The bot token to use.
376- url : str
376+ gateway_url : str
377377 The gateway URL to use. This should not contain a query-string or
378378 fragments.
379379 event_manager : hikari.api.event_manager.EventManager
@@ -417,6 +417,18 @@ class GatewayShardImpl(shard.GatewayShard):
417417 The proxy settings to use while negotiating a websocket.
418418 data_format : str
419419 Data format to use for inbound data. Only supported format is `"json"`.
420+ initial_seq : typing.Optional[int]
421+ The initial session sequence to start at.
422+ initial_session_id : typing.Optional[str]
423+ The initial session id to start with.
424+ initial_resume_gateway_url : typing.Optional[str]
425+ The initial resume gateway url to use.
426+
427+ Raises
428+ ------
429+ ValueError
430+ If not all of `initial_seq`, `initial_session_id`, and `initial_resume_gateway_url`
431+ are passed, with any one of them being given a value.
420432 """
421433
422434 __slots__ : typing .Sequence [str ] = (
@@ -467,24 +479,34 @@ def __init__(
467479 large_threshold : int = 250 ,
468480 shard_id : int = 0 ,
469481 shard_count : int = 1 ,
482+ initial_seq : typing .Optional [int ] = None ,
483+ initial_session_id : typing .Optional [str ] = None ,
484+ initial_resume_gateway_url : typing .Optional [str ] = None ,
470485 http_settings : config .HTTPSettings ,
471486 proxy_settings : config .ProxySettings ,
472487 data_format : str = shard .GatewayDataFormat .JSON ,
473488 event_manager : event_manager_ .EventManager ,
474489 event_factory : event_factory_ .EventFactory ,
475490 token : str ,
476- url : str ,
491+ gateway_url : str ,
477492 ) -> None :
478493 if data_format != shard .GatewayDataFormat .JSON :
479494 raise NotImplementedError (f"Unsupported gateway data format: { data_format } " )
480495
481496 if compression and compression != shard .GatewayCompression .TRANSPORT_ZLIB_STREAM :
482497 raise NotImplementedError (f"Unsupported compression format { compression } " )
483498
499+ if bool (initial_seq ) ^ bool (initial_session_id ) ^ bool (initial_resume_gateway_url ):
500+ # It makes no sense to allow passing RESUME data if not all the data is passed
501+ raise ValueError (
502+ "You must specify exactly all or neither of "
503+ "`initial_seq`, `initial_session_id` or `initial_resume_gateway_url`"
504+ )
505+
484506 self ._activity = initial_activity
485507 self ._event_manager = event_manager
486508 self ._event_factory = event_factory
487- self ._gateway_url = url
509+ self ._gateway_url = gateway_url
488510 self ._handshake_event : typing .Optional [asyncio .Event ] = None
489511 self ._heartbeat_latency = float ("nan" )
490512 self ._http_settings = http_settings
@@ -501,9 +523,9 @@ def __init__(
501523 f"shard { shard_id } non-priority rate limit" , * _NON_PRIORITY_RATELIMIT
502524 )
503525 self ._proxy_settings = proxy_settings
504- self ._resume_gateway_url : typing . Optional [ str ] = None
505- self ._seq : typing . Optional [ int ] = None
506- self ._session_id : typing . Optional [ str ] = None
526+ self ._resume_gateway_url = initial_resume_gateway_url
527+ self ._seq = initial_seq
528+ self ._session_id = initial_session_id
507529 self ._shard_count = shard_count
508530 self ._shard_id = shard_id
509531 self ._status = initial_status
@@ -541,6 +563,18 @@ def is_connected(self) -> bool:
541563 def shard_count (self ) -> int :
542564 return self ._shard_count
543565
566+ @property
567+ def session_id (self ) -> typing .Optional [str ]:
568+ return self ._session_id
569+
570+ @property
571+ def seq (self ) -> typing .Optional [int ]:
572+ return self ._seq
573+
574+ @property
575+ def resume_gateway_url (self ) -> typing .Optional [str ]:
576+ return self ._resume_gateway_url
577+
544578 async def close (self ) -> None :
545579 if not self ._keep_alive_task :
546580 raise errors .ComponentStateConflictError ("Cannot close an inactive shard" )
0 commit comments