1"""Discord's public server widget, trimmed for signed-in members: who's online right now, by name."""
2
3from pydantic import BaseModel, Field
4
5DiscordOnlineStatus = str
6"""One of ``"online"``, ``"idle"`` or ``"dnd"``, as reported by Discord's widget."""
7
8
[docs]
9class DiscordOnlineMember(BaseModel):
10 """One member from the widget's anonymized roster."""
11
12 name: str = Field(
13 description='Display name. Discord calls this "username" on the widget, but it is the server nick or '
14 "display name."
15 )
16 status: DiscordOnlineStatus
17 avatar_url: str | None = Field(
18 description="cdn.discordapp.com/widget-avatars/... URL, or None if Discord did not report one."
19 )
20 activity: str | None = Field(description="The member's current activity or game name, if any.")
21
22
[docs]
23class DiscordOnline(BaseModel):
24 """``GET /api/discord/online`` (members only): the guild widget's live roster, or empty if Discord didn't answer."""
25
26 presence_count: int | None
27 members: list[DiscordOnlineMember]
28 ok: bool = Field(description="False when the widget fetch failed or timed out. members is then always empty.")