1"""Guild configuration schemas."""
2
3from pydantic import BaseModel, ConfigDict, Field, model_validator
4
5
[docs]
6class GuildConfigSchema(BaseModel):
7 """Full guild configuration as returned by the API."""
8
9 model_config = ConfigDict(from_attributes=True)
10
11 guild_id: int
12
13 log_channel_id: int | None
14
15 welcome_channel_id: int | None
16 welcome_message: str
17 auto_role_id: int | None
18 # Defaulted so a bot rolled out before the API (deploys aren't ordered) can still read the config.
19 linked_role_id: int | None = None
20 battlenet_role_id: int | None = None
21 gate_role_id: int | None = None
22 roster_role_id: int | None = None
23 events_forum_channel_id: int | None = None
24
25 leveling_enabled: bool
26 level_up_channel_id: int | None
27 level_up_message: str
28 xp_min: int = Field(description="Lowest XP (experience points) a chat message can award.")
29 xp_max: int = Field(description="Highest XP (experience points) a chat message can award.")
30 xp_cooldown_seconds: int = Field(description="Minimum seconds between XP awards for the same member.")
31 level_roles_stack: bool
32 no_xp_channel_ids: list[int]
33 no_xp_role_ids: list[int]
34
35 automod_enabled: bool
36 automod_block_invites: bool
37 automod_block_links: bool
38 automod_max_mentions: int
39 automod_spam_messages: int
40 automod_spam_seconds: int
41 automod_timeout_seconds: int
42 automod_exempt_role_ids: list[int]
43 automod_exempt_channel_ids: list[int]
44
45 signup_notice_channel_id: int | None = None
46
47 weekly_board_channel_id: int | None = None
48 weekly_board_last_week: str | None = None
49
50 market_report_channel_id: int | None = None
51 market_report_last_day: str | None = None
52
53 away_role_id: int | None = None
54
55 badge_channel_id: int | None = None
56 badge_role_ids: dict[str, int] = Field(default_factory=dict)
57
58 announcement_channel_id: int | None = None
59
60 forever_feed_channel_id: int | None = None
61
62 lfg_channel_id: int | None = None
63 lfg_panel_message_id: int | None = None
64 lfg_ping_role_ids: dict[str, int] = Field(default_factory=dict)
65 pug_role_id: int | None = None
66 """Role every PUG invite grants: hides the server but #sign-the-ledger; each PUG group adds its own role."""
67
68 loot_log_channel_id: int | None = None
69
70
[docs]
71class GuildConfigUpdate(BaseModel):
72 """Partial update. Only fields present in the request body change (``exclude_unset``).
73
74 Send ``null`` to clear an optional channel/role.
75 """
76
77 log_channel_id: int | None = None
78
79 welcome_channel_id: int | None = None
80 welcome_message: str | None = Field(default=None, min_length=1, max_length=2000)
81 auto_role_id: int | None = None
82 linked_role_id: int | None = None
83 battlenet_role_id: int | None = None
84 gate_role_id: int | None = None
85 roster_role_id: int | None = None
86 events_forum_channel_id: int | None = None
87
88 leveling_enabled: bool | None = None
89 level_up_channel_id: int | None = None
90 level_up_message: str | None = Field(default=None, min_length=1, max_length=2000)
91 xp_min: int | None = Field(
92 default=None, ge=0, le=1000, description="Lowest XP (experience points) a chat message can award."
93 )
94 xp_max: int | None = Field(
95 default=None, ge=0, le=1000, description="Highest XP (experience points) a chat message can award."
96 )
97 xp_cooldown_seconds: int | None = Field(
98 default=None, ge=0, le=86400, description="Minimum seconds between XP awards for the same member."
99 )
100 level_roles_stack: bool | None = None
101 no_xp_channel_ids: list[int] | None = None
102 no_xp_role_ids: list[int] | None = None
103
104 automod_enabled: bool | None = None
105 automod_block_invites: bool | None = None
106 automod_block_links: bool | None = None
107 automod_max_mentions: int | None = Field(default=None, ge=0, le=100)
108 automod_spam_messages: int | None = Field(default=None, ge=0, le=100)
109 automod_spam_seconds: int | None = Field(default=None, ge=1, le=600)
110 automod_timeout_seconds: int | None = Field(default=None, ge=0, le=2_419_200)
111 automod_exempt_role_ids: list[int] | None = None
112 automod_exempt_channel_ids: list[int] | None = None
113
114 signup_notice_channel_id: int | None = None
115
116 weekly_board_channel_id: int | None = None
117 weekly_board_last_week: str | None = None
118
119 market_report_channel_id: int | None = None
120 market_report_last_day: str | None = Field(default=None, pattern=r"^\d{4}-\d{2}-\d{2}$")
121
122 away_role_id: int | None = None
123
124 badge_channel_id: int | None = None
125 badge_role_ids: dict[str, int] | None = None
126
127 announcement_channel_id: int | None = None
128
129 forever_feed_channel_id: int | None = None
130
131 lfg_channel_id: int | None = None
132 lfg_panel_message_id: int | None = None
133 lfg_ping_role_ids: dict[str, int] | None = None
134 pug_role_id: int | None = None
135
136 loot_log_channel_id: int | None = None
137
138 @model_validator(mode="after")
139 def _xp_range(self) -> GuildConfigUpdate:
140 if self.xp_min is not None and self.xp_max is not None and self.xp_min > self.xp_max:
141 msg = "xp_min must be <= xp_max"
142 raise ValueError(msg)
143 return self