Skip to content

Commit ebe2e1a

Browse files
authored
feat: add safety alerts channel to guild model (#1589)
* feat: add safety_alerts_channel_id to http modify_guild method * feat: add security_alert_channel to guild model
1 parent 6566dda commit ebe2e1a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

interactions/api/http/http_requests/guild.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ async def modify_guild(
130130
"system_channel_flags",
131131
"rules_channel_id",
132132
"public_updates_channel_id",
133+
"safety_alerts_channel_id",
133134
"preferred_locale",
134135
"features",
135136
"description",

interactions/models/discord/guild.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ class Guild(BaseGuild):
236236
"""A cache of all command permissions for this guild"""
237237
premium_progress_bar_enabled: bool = attrs.field(repr=False, default=False)
238238
"""True if the guild has the boost progress bar enabled"""
239+
safety_alerts_channel_id: Optional[Snowflake_Type] = attrs.field(repr=False, default=None)
240+
"""The id of the channel where admins and moderators of Community guilds receive safety alerts from Discord."""
239241

240242
_owner_id: Snowflake_Type = attrs.field(repr=False, converter=to_snowflake)
241243
_channel_ids: Set[Snowflake_Type] = attrs.field(repr=False, factory=set)
@@ -396,6 +398,11 @@ def public_updates_channel(self) -> Optional["models.GuildText"]:
396398
"""Returns the channel where server staff receive notices from Discord."""
397399
return self._client.cache.get_channel(self.public_updates_channel_id)
398400

401+
@property
402+
def safety_alerts_channel(self) -> Optional["models.GuildText"]:
403+
"""Returns the channel where server staff receive safety alerts from Discord."""
404+
return self._client.cache.get_channel(self.safety_alerts_channel_id)
405+
399406
@property
400407
def emoji_limit(self) -> int:
401408
"""The maximum number of emoji this guild can have."""
@@ -759,6 +766,7 @@ async def edit(
759766
banner: Absent[Optional[UPLOADABLE_TYPE]] = MISSING,
760767
rules_channel: Absent[Optional[Union["models.GuildText", Snowflake_Type]]] = MISSING,
761768
public_updates_channel: Absent[Optional[Union["models.GuildText", Snowflake_Type]]] = MISSING,
769+
safety_alerts_channel: Absent[Optional[Union["models.GuildText", Snowflake_Type]]] = MISSING,
762770
preferred_locale: Absent[Optional[str]] = MISSING,
763771
premium_progress_bar_enabled: Absent[Optional[bool]] = False,
764772
# ToDo: Fill in guild features. No idea how this works - https://discord.com/developers/docs/resources/guild#guild-object-guild-features
@@ -785,6 +793,7 @@ async def edit(
785793
system_channel_flags: The new settings for the system channel.
786794
rules_channel: The text channel where your rules and community guidelines are displayed.
787795
public_updates_channel: The text channel where updates from discord should appear.
796+
safety_alerts_channel: The text channel where safety alerts from discord should appear.
788797
preferred_locale: The new preferred locale of the guild. Must be an ISO 639 code.
789798
premium_progress_bar_enabled: The status of the Nitro boost bar.
790799
features: The enabled guild features
@@ -811,6 +820,7 @@ async def edit(
811820
system_channel_flags=int(system_channel_flags) if system_channel_flags else MISSING,
812821
rules_channel_id=to_snowflake(rules_channel) if rules_channel else MISSING,
813822
public_updates_channel_id=to_snowflake(public_updates_channel) if public_updates_channel else MISSING,
823+
safety_alerts_channel_id=to_snowflake(safety_alerts_channel) if safety_alerts_channel else MISSING,
814824
preferred_locale=preferred_locale,
815825
premium_progress_bar_enabled=premium_progress_bar_enabled if premium_progress_bar_enabled else False,
816826
features=features,

0 commit comments

Comments
 (0)