Skip to content

Commit 99a5836

Browse files
committed
feat: add get_discord_bot_id() client method
Calls GET /api/discord/bot, returns the StackCoin Discord bot's snowflake ID. Also regenerates models from updated OpenAPI spec.
1 parent 7bc89cc commit 99a5836

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/stackcoin/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .errors import StackCoinError
1010
from .models import (
1111
CreateRequestResponse,
12+
DiscordBotResponse,
1213
DiscordGuild,
1314
DiscordGuildsResponse,
1415
EventsResponse,
@@ -216,6 +217,13 @@ async def get_events(self, *, since_id: int = 0) -> list[AnyEvent]:
216217

217218
return all_events
218219

220+
async def get_discord_bot_id(self) -> str:
221+
"""Return the Discord user ID of the StackCoin bot."""
222+
resp = await self._http.get("/api/discord/bot")
223+
self._raise_for_error(resp)
224+
bot = DiscordBotResponse.model_validate(resp.json())
225+
return bot.discord_id
226+
219227
async def get_discord_guilds(self) -> list[DiscordGuild]:
220228
"""Return all Discord guilds."""
221229
resp = await self._http.get("/api/discord/guilds")

src/stackcoin/gateway.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ async def _dispatch_event(self, typed_event: AnyEvent) -> None:
148148
try:
149149
await handler(typed_event)
150150
except Exception:
151-
logger.exception("Error in %s handler for event %s", typed_event.type, typed_event.id)
151+
logger.exception(
152+
"Error in %s handler for event %s", typed_event.type, typed_event.id
153+
)
152154

153155
if typed_event.id > 0 and self._on_event_id:
154156
try:

src/stackcoin/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: openapi.json
3-
# timestamp: 2026-03-06T23:08:44+00:00
3+
# timestamp: 2026-03-07T01:20:04+00:00
44

55
from __future__ import annotations
66

@@ -36,6 +36,10 @@ class CreateRequestResponse(BaseModel):
3636
success: bool = Field(..., description="Whether the operation succeeded")
3737

3838

39+
class DiscordBotResponse(BaseModel):
40+
discord_id: str = Field(..., description="The Discord snowflake ID of the StackCoin bot")
41+
42+
3943
class DiscordGuild(BaseModel):
4044
designated_channel_snowflake: str | None = Field(
4145
None, description="Designated channel snowflake ID"

0 commit comments

Comments
 (0)