Skip to content

Commit baef57d

Browse files
AstreaTSSi0bs
andauthored
feat: add start_time(s) for AutoShardedClient (#1482)
* feat: add start_time(s) for AutoShardedClient * feat: make start_times a dict * docs: make start_times docstring clearer Co-authored-by: Sophia <41456914+i0bs@users.noreply.github.com> Signed-off-by: Astrea <25420078+AstreaTSS@users.noreply.github.com> --------- Signed-off-by: Astrea <25420078+AstreaTSS@users.noreply.github.com> Co-authored-by: Sophia <41456914+i0bs@users.noreply.github.com>
1 parent f3583b1 commit baef57d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

interactions/client/auto_shard_client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import time
3+
from datetime import datetime
34
from collections import defaultdict
45
from typing import TYPE_CHECKING, Optional
56

@@ -68,6 +69,16 @@ def latencies(self) -> dict[int, float]:
6869
"""
6970
return {state.shard_id: state.latency for state in self._connection_states}
7071

72+
@property
73+
def start_time(self) -> datetime:
74+
"""The start time of the first shard of the bot."""
75+
return next((state.start_time for state in self._connection_states), MISSING) # type: ignore
76+
77+
@property
78+
def start_times(self) -> dict[int, datetime]:
79+
"""The start times of all shards of the bot, keyed by each shard ID."""
80+
return {state.shard_id: state.start_time for state in self._connection_states} # type: ignore
81+
7182
async def stop(self) -> None:
7283
"""Shutdown the bot."""
7384
self.logger.debug("Stopping the bot.")

0 commit comments

Comments
 (0)