Client¶
The client layer lives in website/client/ and provides low-level HTTP clients for external API integrations.
Clients:
- Handle HTTP requests, retries, and rate limiting
- Raise domain exceptions on failure (e.g.
DiscordAPIError) - Contain no business logic — that belongs in services
Overview¶
| Client | Description |
|---|---|
Discord |
Low-level Discord REST API client with retry logic and rate-limit handling |
API Reference¶
Client layer for external API integrations.
Discord
¶
Low-level Discord API client.
Handles HTTP requests to the Discord API with retry logic and rate limiting. For business logic, use DiscordService which wraps this client.
Attributes:
| Name | Type | Description |
|---|---|---|
guild_id |
The Discord guild (server) ID. |
|
authorization |
The bot token for authentication. |
|
headers |
HTTP headers for API requests. |
Source code in website/client/discord.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
get_user(user_id)
¶
Fetch a guild member's data from Discord.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
Discord user ID. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with member data including user, nick, and roles. |
Source code in website/client/discord.py
send_message(content, channel_id)
¶
Send a text message to a Discord channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Message content string. |
required |
channel_id
|
str
|
Target channel ID. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with the created message data. |
Source code in website/client/discord.py
delete_message(msg_id, channel_id)
¶
Delete a message from a Discord channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg_id
|
str
|
Message ID to delete. |
required |
channel_id
|
str
|
Channel containing the message. |
required |
Source code in website/client/discord.py
send_embed_message(embed, channel_id)
¶
Send an embed message to a Discord channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
embed
|
dict
|
Embed dict following Discord embed structure. |
required |
channel_id
|
str
|
Target channel ID. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with the created message data. |
Source code in website/client/discord.py
edit_embed_message(msg_id, embed, channel_id)
¶
Edit an existing embed message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg_id
|
str
|
Message ID to edit. |
required |
embed
|
dict
|
Updated embed dict. |
required |
channel_id
|
str
|
Channel containing the message. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with the updated message data. |
Source code in website/client/discord.py
pin_message(msg_id, channel_id)
¶
Pin an existing message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
msg_id
|
str
|
Message ID to pin. |
required |
channel_id
|
str
|
Channel containing the message. |
required |
Source code in website/client/discord.py
create_channel(channel_name, parent_id, role_id, gm_id)
¶
Create a text channel in the guild with role-based permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_name
|
str
|
Display name for the channel. |
required |
parent_id
|
str
|
Parent category ID. |
required |
role_id
|
str
|
Role ID for player permissions. |
required |
gm_id
|
str
|
GM user ID for elevated permissions. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with the created channel data. |
Source code in website/client/discord.py
get_channel(channel_id)
¶
Fetch channel data from Discord.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id
|
str
|
Discord channel ID. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with channel data. |
Source code in website/client/discord.py
delete_channel(channel_id)
¶
Delete a Discord channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_id
|
str
|
Channel ID to delete. |
required |
create_role(role_name, permissions, color)
¶
Create a new guild role.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role_name
|
str
|
Display name for the role. |
required |
permissions
|
str
|
Permission bitfield string. |
required |
color
|
int
|
Role color as integer. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with the created role data. |
Source code in website/client/discord.py
get_role(role_id)
¶
Fetch a guild role by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role_id
|
str
|
Role ID to look up. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Dict with role data, or a fallback dict if not found. |
Source code in website/client/discord.py
delete_role(role_id)
¶
Delete a guild role.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role_id
|
str
|
Role ID to delete. |
required |
add_role_to_user(user_id, role_id)
¶
Assign a role to a guild member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
Discord user ID. |
required |
role_id
|
str
|
Role ID to assign. |
required |
Source code in website/client/discord.py
remove_role_from_user(user_id, role_id)
¶
Remove a role from a guild member.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
Discord user ID. |
required |
role_id
|
str
|
Role ID to remove. |
required |