|
2 | 2 | import time
|
3 | 3 | from datetime import datetime
|
4 | 4 | from collections import defaultdict
|
5 |
| -from typing import TYPE_CHECKING, Optional |
| 5 | +from typing import TYPE_CHECKING, Optional, List |
6 | 6 |
|
7 | 7 | import interactions.api.events as events
|
8 | 8 | from interactions.api.events import ShardConnect
|
@@ -35,6 +35,8 @@ def __init__(self, *args, **kwargs) -> None:
|
35 | 35 | self.auto_sharding = "total_shards" not in kwargs
|
36 | 36 | super().__init__(*args, **kwargs)
|
37 | 37 |
|
| 38 | + self.shard_ids: Optional[List[int]] = kwargs.get("shard_ids", None) |
| 39 | + |
38 | 40 | self._connection_state = None
|
39 | 41 |
|
40 | 42 | self._connection_states: list[ConnectionState] = []
|
@@ -244,9 +246,13 @@ async def login(self, token: str | None = None) -> None:
|
244 | 246 | )
|
245 | 247 |
|
246 | 248 | self.logger.debug(f"Starting bot with {self.total_shards} shard{'s' if self.total_shards != 1 else ''}")
|
247 |
| - self._connection_states: list[ConnectionState] = [ |
248 |
| - ConnectionState(self, self.intents, shard_id) for shard_id in range(self.total_shards) |
249 |
| - ] |
| 249 | + |
| 250 | + if self.shard_ids: |
| 251 | + self._connection_states = [ConnectionState(self, self.intents, shard_id) for shard_id in self.shard_ids] |
| 252 | + else: |
| 253 | + self._connection_states = [ |
| 254 | + ConnectionState(self, self.intents, shard_id) for shard_id in range(self.total_shards) |
| 255 | + ] |
250 | 256 |
|
251 | 257 | async def change_presence(
|
252 | 258 | self,
|
|
0 commit comments