From b78e8399202fb30cd5cdb1916409144200ff5260 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Wed, 14 Dec 2022 11:45:57 -0300 Subject: [PATCH 01/11] feat: add `mention_raid_protection_enabled` parameter --- disnake/automod.py | 31 +++++++++++++++++++++++++------ disnake/types/automod.py | 1 + 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/disnake/automod.py b/disnake/automod.py index 4f48a0ebea..11b4ffed6c 100644 --- a/disnake/automod.py +++ b/disnake/automod.py @@ -216,12 +216,12 @@ class AutoModTriggerMetadata: Based on the trigger type, different fields can be used with various limits: .. csv-table:: - :header: "Trigger Type", ``keyword_filter``, ``regex_patterns``, ``presets``, ``allow_list``, ``mention_total_limit`` + :header: "Trigger Type", ``keyword_filter``, ``regex_patterns``, ``presets``, ``allow_list``, ``mention_total_limit``, ``mention_raid_protection_enabled`` - :attr:`~AutoModTriggerType.keyword`, ✅ (x1000), ✅ (x10), ❌, ✅ (x100), ❌ - :attr:`~AutoModTriggerType.spam`, ❌, ❌, ❌, ❌, ❌ - :attr:`~AutoModTriggerType.keyword_preset`, ❌, ❌, ✅, ✅ (x1000), ❌ - :attr:`~AutoModTriggerType.mention_spam`, ❌, ❌, ❌, ❌, ✅ + :attr:`~AutoModTriggerType.keyword`, ✅ (x1000), ✅ (x10), ❌, ✅ (x100), ❌, ❌ + :attr:`~AutoModTriggerType.spam`, ❌, ❌, ❌, ❌, ❌, ❌ + :attr:`~AutoModTriggerType.keyword_preset`, ❌, ❌, ✅, ✅ (x1000), ❌, ❌ + :attr:`~AutoModTriggerType.mention_spam`, ❌, ❌, ❌, ❌, ✅, ✅ .. versionadded:: 2.6 @@ -256,6 +256,11 @@ class AutoModTriggerMetadata: mention_total_limit: Optional[:class:`int`] The maximum number of mentions (members + roles) allowed, between 1 and 50. Used with :attr:`AutoModTriggerType.mention_spam`. + + mention_raid_protection_enabled: Optional[:class:`bool`] + TBD. Used with :attr:`AutoModTriggerType.mention_spam`. + + .. versionadded:: 2.8 """ __slots__ = ( @@ -264,6 +269,7 @@ class AutoModTriggerMetadata: "presets", "allow_list", "mention_total_limit", + "mention_raid_protection_enabled", ) @overload @@ -296,7 +302,7 @@ def __init__( ... @overload - def __init__(self, *, mention_total_limit: int) -> None: + def __init__(self, *, mention_total_limit: int, mention_raid_protection_enabled: bool) -> None: ... def __init__( @@ -307,12 +313,14 @@ def __init__( presets: Optional[AutoModKeywordPresets] = None, allow_list: Optional[Sequence[str]] = None, mention_total_limit: Optional[int] = None, + mention_raid_protection_enabled: Optional[bool] = None, ) -> None: self.keyword_filter: Optional[Sequence[str]] = keyword_filter self.regex_patterns: Optional[Sequence[str]] = regex_patterns self.presets: Optional[AutoModKeywordPresets] = presets self.allow_list: Optional[Sequence[str]] = allow_list self.mention_total_limit: Optional[int] = mention_total_limit + self.mention_raid_protection_enabled: Optional[bool] = mention_raid_protection_enabled def with_changes( self, @@ -322,6 +330,7 @@ def with_changes( presets: Optional[AutoModKeywordPresets] = MISSING, allow_list: Optional[Sequence[str]] = MISSING, mention_total_limit: Optional[int] = MISSING, + mention_raid_protection_enabled: Optional[bool] = MISSING, ) -> Self: """ Returns a new instance with the given changes applied. @@ -340,6 +349,11 @@ def with_changes( mention_total_limit=( self.mention_total_limit if mention_total_limit is MISSING else mention_total_limit ), + mention_raid_protection_enabled=( + self.mention_raid_protection_enabled + if mention_raid_protection_enabled is MISSING + else mention_raid_protection_enabled + ), ) @classmethod @@ -355,6 +369,7 @@ def _from_dict(cls, data: AutoModTriggerMetadataPayload) -> Self: presets=presets, allow_list=data.get("allow_list"), mention_total_limit=data.get("mention_total_limit"), + mention_raid_protection_enabled=data.get("mention_raid_protection_enabled"), ) def to_dict(self) -> AutoModTriggerMetadataPayload: @@ -369,6 +384,8 @@ def to_dict(self) -> AutoModTriggerMetadataPayload: data["allow_list"] = list(self.allow_list) if self.mention_total_limit is not None: data["mention_total_limit"] = self.mention_total_limit + if self.mention_raid_protection_enabled is not None: + data["mention_raid_protection_enabled"] = self.mention_raid_protection_enabled return data def __repr__(self) -> str: @@ -383,6 +400,8 @@ def __repr__(self) -> str: s += f" allow_list={self.allow_list!r}" if self.mention_total_limit is not None: s += f" mention_total_limit={self.mention_total_limit!r}" + if self.mention_raid_protection_enabled is not None: + s += f" mention_raid_protection_enabled={self.mention_raid_protection_enabled!r}" return f"{s}>" diff --git a/disnake/types/automod.py b/disnake/types/automod.py index 27b77c024e..29e51b2063 100644 --- a/disnake/types/automod.py +++ b/disnake/types/automod.py @@ -44,6 +44,7 @@ class AutoModTriggerMetadata(TypedDict, total=False): presets: List[AutoModPresetType] allow_list: List[str] mention_total_limit: int + mention_raid_protection_enabled: bool class AutoModRule(TypedDict): From 0dfef214c3e22ae1a6ccc99d5e518045d9024aa1 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Wed, 14 Dec 2022 11:46:25 -0300 Subject: [PATCH 02/11] docs: add changelog entry --- changelog/895.feature.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/895.feature.rst diff --git a/changelog/895.feature.rst b/changelog/895.feature.rst new file mode 100644 index 0000000000..de25e43526 --- /dev/null +++ b/changelog/895.feature.rst @@ -0,0 +1 @@ +Implement new :attr:`AutoModTriggerMetadata.mention_raid_protection_enabled` parameter. From 12e8951fcb6365d1c565fcb0f071b4db0ad3c35b Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Wed, 21 Dec 2022 23:19:09 -0300 Subject: [PATCH 03/11] docs: update documentation --- disnake/automod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/automod.py b/disnake/automod.py index 11b4ffed6c..a6d40a3df2 100644 --- a/disnake/automod.py +++ b/disnake/automod.py @@ -258,7 +258,7 @@ class AutoModTriggerMetadata: The maximum number of mentions (members + roles) allowed, between 1 and 50. Used with :attr:`AutoModTriggerType.mention_spam`. mention_raid_protection_enabled: Optional[:class:`bool`] - TBD. Used with :attr:`AutoModTriggerType.mention_spam`. + Whether to automatically detect mention raids. Used with :attr:`AutoModTriggerType.mention_spam`. .. versionadded:: 2.8 """ From 711604691984496a2350e278563468fcb5d354fe Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Wed, 21 Dec 2022 23:19:53 -0300 Subject: [PATCH 04/11] feat: add support for `safety_alerts_channel_id` and `RAID_ALERTS_ENABLED` feature --- disnake/guild.py | 62 +++++++++++++++++++++++++++++++++++++++++- disnake/types/guild.py | 1 + 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/disnake/guild.py b/disnake/guild.py index 94d6ca2bd3..fb5de3ef88 100644 --- a/disnake/guild.py +++ b/disnake/guild.py @@ -212,6 +212,7 @@ class Guild(Hashable): - ``PARTNERED``: Guild is a partnered server. - ``PREVIEW_ENABLED``: Guild can be viewed before being accepted via Membership Screening. - ``PRIVATE_THREADS``: Guild has access to create private threads (no longer has any effect). + - ``RAID_ALERTS_ENABLED``: Guild has enabled alerts for join raids in the configured safety alerts channel. - ``ROLE_ICONS``: Guild has access to role icons. - ``SEVEN_DAY_THREAD_ARCHIVE``: Guild has access to the seven day archive time for threads (no longer has any effect). - ``TEXT_IN_VOICE_ENABLED``: Guild has text in voice channels enabled (no longer has any effect). @@ -329,6 +330,7 @@ class Guild(Hashable): "_scheduled_events", "_threads", "_region", + "_safety_alerts_channel_id", ) _PREMIUM_GUILD_LIMITS: ClassVar[Dict[Optional[int], _GuildLimit]] = { @@ -546,6 +548,9 @@ def _from_data(self, guild: GuildPayload) -> None: self.widget_enabled: Optional[bool] = guild.get("widget_enabled") self.widget_channel_id: Optional[int] = utils._get_as_snowflake(guild, "widget_channel_id") self.vanity_url_code: Optional[str] = guild.get("vanity_url_code") + self._safety_alerts_channel_id: Optional[int] = utils._get_as_snowflake( + guild, "safety_alerts_channel_id" + ) stage_instances = guild.get("stage_instances") if stage_instances is not None: @@ -832,6 +837,19 @@ def public_updates_channel(self) -> Optional[TextChannel]: channel_id = self._public_updates_channel_id return channel_id and self._channels.get(channel_id) # type: ignore + @property + def safety_alerts_channel(self) -> Optional[TextChannel]: + """Optional[:class:`TextChannel`]: Return's the guild's channel where admins and + moderators of the guild receive safety alerts from Discord. The guild must be a + Community guild. + + If no channel is set, then this returns ``None``. + + .. versionadded:: 2.8 + """ + channel_id = self._safety_alerts_channel_id + return channel_id and self._channels.get(channel_id) # type: ignore + @property def emoji_limit(self) -> int: """:class:`int`: The maximum number of emoji slots this guild has.""" @@ -1784,6 +1802,7 @@ async def edit( discovery_splash: Optional[AssetBytes] = MISSING, community: bool = MISSING, invites_disabled: bool = MISSING, + raid_alerts_enabled: bool = MISSING, afk_channel: Optional[VoiceChannel] = MISSING, owner: Snowflake = MISSING, afk_timeout: int = MISSING, @@ -1796,6 +1815,7 @@ async def edit( preferred_locale: Locale = MISSING, rules_channel: Optional[TextChannel] = MISSING, public_updates_channel: Optional[TextChannel] = MISSING, + safety_alerts_channel: Optional[TextChannel] = MISSING, premium_progress_bar_enabled: bool = MISSING, ) -> Guild: """ @@ -1877,6 +1897,16 @@ async def edit( .. versionadded:: 2.6 + raid_alerts_enabled: :class:`bool` + Whether the guild has enabled join raid alerts. + + This is only available to guilds that contain ``COMMUNITY`` + in :attr:`Guild.features`. + + This cannot be changed at the same time as the ``community`` feature due a Discord API limitation. + + .. versionadded:: 2.8 + afk_channel: Optional[:class:`VoiceChannel`] The new channel that is the AFK channel. Could be ``None`` for no AFK channel. afk_timeout: :class:`int` @@ -1911,6 +1941,13 @@ async def edit( The new channel that is used for public updates from Discord. This is only available to guilds that contain ``COMMUNITY`` in :attr:`Guild.features`. Could be ``None`` for no public updates channel. + safety_alerts_channel: Optional[:class:`TextChannel`] + The new channel that is used for safety alerts. This is only available to + guilds that contain ``COMMUNITY`` in :attr:`Guild.features`. Could be ``None`` for no + safety alerts channel. + + .. versionadded:: 2.8 + premium_progress_bar_enabled: :class:`bool` Whether the server boost progress bar is enabled. reason: Optional[:class:`str`] @@ -2000,6 +2037,12 @@ async def edit( else: fields["public_updates_channel_id"] = public_updates_channel.id + if safety_alerts_channel is not MISSING: + if safety_alerts_channel is None: + fields["safety_alerts_channel_id"] = safety_alerts_channel + else: + fields["safety_alerts_channel_id"] = safety_alerts_channel.id + if owner is not MISSING: if self.owner_id != self._state.self_id: raise ValueError("To transfer ownership you must be the owner of the guild.") @@ -2024,7 +2067,11 @@ async def edit( fields["system_channel_flags"] = system_channel_flags.value - if community is not MISSING or invites_disabled is not MISSING: + if ( + community is not MISSING + or invites_disabled is not MISSING + or raid_alerts_enabled is not MISSING + ): # If we don't have complete feature information for the guild, # it is possible to disable or enable other features that we didn't intend to touch. # To enable or disable a feature, we will need to provide all of the existing features in advance. @@ -2059,6 +2106,19 @@ async def edit( else: features.discard("INVITES_DISABLED") + if raid_alerts_enabled is not MISSING: + if community is not MISSING: + raise ValueError( + "cannot modify both the COMMUNITY feature and RAID_ALERTS_ENABLED feature at the " + "same time due to a discord limitation." + ) + if not isinstance(raid_alerts_enabled, bool): + raise TypeError("raid_alerts_enabled must be a bool") + if raid_alerts_enabled: + features.add("RAID_ALERTS_ENABLED") + else: + features.discard("RAID_ALERTS_ENABLED") + fields["features"] = list(features) if premium_progress_bar_enabled is not MISSING: diff --git a/disnake/types/guild.py b/disnake/types/guild.py index c94e2da69e..60e2c57994 100644 --- a/disnake/types/guild.py +++ b/disnake/types/guild.py @@ -62,6 +62,7 @@ class UnavailableGuild(TypedDict): "PREVIEW_ENABLED", "PRIVATE_THREADS", # deprecated "RELAY_ENABLED", + "RAID_ALERTS_ENABLED", "ROLE_ICONS", "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE", # not yet documented/finalised "ROLE_SUBSCRIPTIONS_ENABLED", # not yet documented/finalised From d2b63cfb168cfc7ac7b131527dc1581cc9cb69e7 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Wed, 21 Dec 2022 23:23:47 -0300 Subject: [PATCH 05/11] changelog: rename changelog entry --- changelog/{895.feature.rst => 898.feature.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog/{895.feature.rst => 898.feature.rst} (100%) diff --git a/changelog/895.feature.rst b/changelog/898.feature.rst similarity index 100% rename from changelog/895.feature.rst rename to changelog/898.feature.rst From f893521415cb812664604963e96d71903c7da11d Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Wed, 21 Dec 2022 23:28:15 -0300 Subject: [PATCH 06/11] changelog: update changelog entry --- changelog/898.feature.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog/898.feature.rst b/changelog/898.feature.rst index de25e43526..8066ef473b 100644 --- a/changelog/898.feature.rst +++ b/changelog/898.feature.rst @@ -1 +1,2 @@ Implement new :attr:`AutoModTriggerMetadata.mention_raid_protection_enabled` parameter. +Implement ``raid_alerts_enabled`` and ``safety_alerts_channel`` parameters in :meth:`Guild.edit`. From 636864252d5f5c6c9561e7f0852c075c644ec046 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Thu, 22 Dec 2022 00:00:16 -0300 Subject: [PATCH 07/11] fix: add safety_alerts_channel_id in http --- disnake/http.py | 1 + 1 file changed, 1 insertion(+) diff --git a/disnake/http.py b/disnake/http.py index 62aafbb4f4..2122402187 100644 --- a/disnake/http.py +++ b/disnake/http.py @@ -1337,6 +1337,7 @@ def edit_guild( "public_updates_channel_id", "preferred_locale", "premium_progress_bar_enabled", + "safety_alerts_channel_id", ) payload = {k: v for k, v in fields.items() if k in valid_keys} From bfa0f98fc6f2bfa2c620cfbd63788f8d112c53b7 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Thu, 22 Dec 2022 00:06:52 -0300 Subject: [PATCH 08/11] misc: minor changes --- changelog/898.feature.rst | 3 +-- disnake/types/guild.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/changelog/898.feature.rst b/changelog/898.feature.rst index 8066ef473b..f495a6223b 100644 --- a/changelog/898.feature.rst +++ b/changelog/898.feature.rst @@ -1,2 +1 @@ -Implement new :attr:`AutoModTriggerMetadata.mention_raid_protection_enabled` parameter. -Implement ``raid_alerts_enabled`` and ``safety_alerts_channel`` parameters in :meth:`Guild.edit`. +Implement new :attr:`AutoModTriggerMetadata.mention_raid_protection_enabled` parameter. Implement ``raid_alerts_enabled`` and ``safety_alerts_channel`` parameters in :meth:`Guild.edit`. diff --git a/disnake/types/guild.py b/disnake/types/guild.py index 60e2c57994..6683682e12 100644 --- a/disnake/types/guild.py +++ b/disnake/types/guild.py @@ -127,6 +127,7 @@ class Guild(_BaseGuildPreview): nsfw_level: NSFWLevel stickers: NotRequired[List[GuildSticker]] premium_progress_bar_enabled: bool + safety_alerts_channel_id: Optional[Snowflake] # specific to GUILD_CREATE event joined_at: NotRequired[Optional[str]] From 46b68c7fcac43f7d68645c5b09a74ca93781a998 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Thu, 22 Dec 2022 13:58:59 -0300 Subject: [PATCH 09/11] misc: remove raid alerts stuff --- changelog/898.feature.rst | 2 +- disnake/guild.py | 62 +-------------------------------------- disnake/http.py | 1 - disnake/types/guild.py | 2 -- 4 files changed, 2 insertions(+), 65 deletions(-) diff --git a/changelog/898.feature.rst b/changelog/898.feature.rst index f495a6223b..de25e43526 100644 --- a/changelog/898.feature.rst +++ b/changelog/898.feature.rst @@ -1 +1 @@ -Implement new :attr:`AutoModTriggerMetadata.mention_raid_protection_enabled` parameter. Implement ``raid_alerts_enabled`` and ``safety_alerts_channel`` parameters in :meth:`Guild.edit`. +Implement new :attr:`AutoModTriggerMetadata.mention_raid_protection_enabled` parameter. diff --git a/disnake/guild.py b/disnake/guild.py index fb5de3ef88..94d6ca2bd3 100644 --- a/disnake/guild.py +++ b/disnake/guild.py @@ -212,7 +212,6 @@ class Guild(Hashable): - ``PARTNERED``: Guild is a partnered server. - ``PREVIEW_ENABLED``: Guild can be viewed before being accepted via Membership Screening. - ``PRIVATE_THREADS``: Guild has access to create private threads (no longer has any effect). - - ``RAID_ALERTS_ENABLED``: Guild has enabled alerts for join raids in the configured safety alerts channel. - ``ROLE_ICONS``: Guild has access to role icons. - ``SEVEN_DAY_THREAD_ARCHIVE``: Guild has access to the seven day archive time for threads (no longer has any effect). - ``TEXT_IN_VOICE_ENABLED``: Guild has text in voice channels enabled (no longer has any effect). @@ -330,7 +329,6 @@ class Guild(Hashable): "_scheduled_events", "_threads", "_region", - "_safety_alerts_channel_id", ) _PREMIUM_GUILD_LIMITS: ClassVar[Dict[Optional[int], _GuildLimit]] = { @@ -548,9 +546,6 @@ def _from_data(self, guild: GuildPayload) -> None: self.widget_enabled: Optional[bool] = guild.get("widget_enabled") self.widget_channel_id: Optional[int] = utils._get_as_snowflake(guild, "widget_channel_id") self.vanity_url_code: Optional[str] = guild.get("vanity_url_code") - self._safety_alerts_channel_id: Optional[int] = utils._get_as_snowflake( - guild, "safety_alerts_channel_id" - ) stage_instances = guild.get("stage_instances") if stage_instances is not None: @@ -837,19 +832,6 @@ def public_updates_channel(self) -> Optional[TextChannel]: channel_id = self._public_updates_channel_id return channel_id and self._channels.get(channel_id) # type: ignore - @property - def safety_alerts_channel(self) -> Optional[TextChannel]: - """Optional[:class:`TextChannel`]: Return's the guild's channel where admins and - moderators of the guild receive safety alerts from Discord. The guild must be a - Community guild. - - If no channel is set, then this returns ``None``. - - .. versionadded:: 2.8 - """ - channel_id = self._safety_alerts_channel_id - return channel_id and self._channels.get(channel_id) # type: ignore - @property def emoji_limit(self) -> int: """:class:`int`: The maximum number of emoji slots this guild has.""" @@ -1802,7 +1784,6 @@ async def edit( discovery_splash: Optional[AssetBytes] = MISSING, community: bool = MISSING, invites_disabled: bool = MISSING, - raid_alerts_enabled: bool = MISSING, afk_channel: Optional[VoiceChannel] = MISSING, owner: Snowflake = MISSING, afk_timeout: int = MISSING, @@ -1815,7 +1796,6 @@ async def edit( preferred_locale: Locale = MISSING, rules_channel: Optional[TextChannel] = MISSING, public_updates_channel: Optional[TextChannel] = MISSING, - safety_alerts_channel: Optional[TextChannel] = MISSING, premium_progress_bar_enabled: bool = MISSING, ) -> Guild: """ @@ -1897,16 +1877,6 @@ async def edit( .. versionadded:: 2.6 - raid_alerts_enabled: :class:`bool` - Whether the guild has enabled join raid alerts. - - This is only available to guilds that contain ``COMMUNITY`` - in :attr:`Guild.features`. - - This cannot be changed at the same time as the ``community`` feature due a Discord API limitation. - - .. versionadded:: 2.8 - afk_channel: Optional[:class:`VoiceChannel`] The new channel that is the AFK channel. Could be ``None`` for no AFK channel. afk_timeout: :class:`int` @@ -1941,13 +1911,6 @@ async def edit( The new channel that is used for public updates from Discord. This is only available to guilds that contain ``COMMUNITY`` in :attr:`Guild.features`. Could be ``None`` for no public updates channel. - safety_alerts_channel: Optional[:class:`TextChannel`] - The new channel that is used for safety alerts. This is only available to - guilds that contain ``COMMUNITY`` in :attr:`Guild.features`. Could be ``None`` for no - safety alerts channel. - - .. versionadded:: 2.8 - premium_progress_bar_enabled: :class:`bool` Whether the server boost progress bar is enabled. reason: Optional[:class:`str`] @@ -2037,12 +2000,6 @@ async def edit( else: fields["public_updates_channel_id"] = public_updates_channel.id - if safety_alerts_channel is not MISSING: - if safety_alerts_channel is None: - fields["safety_alerts_channel_id"] = safety_alerts_channel - else: - fields["safety_alerts_channel_id"] = safety_alerts_channel.id - if owner is not MISSING: if self.owner_id != self._state.self_id: raise ValueError("To transfer ownership you must be the owner of the guild.") @@ -2067,11 +2024,7 @@ async def edit( fields["system_channel_flags"] = system_channel_flags.value - if ( - community is not MISSING - or invites_disabled is not MISSING - or raid_alerts_enabled is not MISSING - ): + if community is not MISSING or invites_disabled is not MISSING: # If we don't have complete feature information for the guild, # it is possible to disable or enable other features that we didn't intend to touch. # To enable or disable a feature, we will need to provide all of the existing features in advance. @@ -2106,19 +2059,6 @@ async def edit( else: features.discard("INVITES_DISABLED") - if raid_alerts_enabled is not MISSING: - if community is not MISSING: - raise ValueError( - "cannot modify both the COMMUNITY feature and RAID_ALERTS_ENABLED feature at the " - "same time due to a discord limitation." - ) - if not isinstance(raid_alerts_enabled, bool): - raise TypeError("raid_alerts_enabled must be a bool") - if raid_alerts_enabled: - features.add("RAID_ALERTS_ENABLED") - else: - features.discard("RAID_ALERTS_ENABLED") - fields["features"] = list(features) if premium_progress_bar_enabled is not MISSING: diff --git a/disnake/http.py b/disnake/http.py index 2122402187..62aafbb4f4 100644 --- a/disnake/http.py +++ b/disnake/http.py @@ -1337,7 +1337,6 @@ def edit_guild( "public_updates_channel_id", "preferred_locale", "premium_progress_bar_enabled", - "safety_alerts_channel_id", ) payload = {k: v for k, v in fields.items() if k in valid_keys} diff --git a/disnake/types/guild.py b/disnake/types/guild.py index 6683682e12..c94e2da69e 100644 --- a/disnake/types/guild.py +++ b/disnake/types/guild.py @@ -62,7 +62,6 @@ class UnavailableGuild(TypedDict): "PREVIEW_ENABLED", "PRIVATE_THREADS", # deprecated "RELAY_ENABLED", - "RAID_ALERTS_ENABLED", "ROLE_ICONS", "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE", # not yet documented/finalised "ROLE_SUBSCRIPTIONS_ENABLED", # not yet documented/finalised @@ -127,7 +126,6 @@ class Guild(_BaseGuildPreview): nsfw_level: NSFWLevel stickers: NotRequired[List[GuildSticker]] premium_progress_bar_enabled: bool - safety_alerts_channel_id: Optional[Snowflake] # specific to GUILD_CREATE event joined_at: NotRequired[Optional[str]] From 6a402e35cd0c2abfea50453c7d6e8e788250285c Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Tue, 27 Dec 2022 14:45:50 -0300 Subject: [PATCH 10/11] feat: add `False` default to overload --- disnake/automod.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/disnake/automod.py b/disnake/automod.py index a6d40a3df2..9059e2f6be 100644 --- a/disnake/automod.py +++ b/disnake/automod.py @@ -260,6 +260,8 @@ class AutoModTriggerMetadata: mention_raid_protection_enabled: Optional[:class:`bool`] Whether to automatically detect mention raids. Used with :attr:`AutoModTriggerType.mention_spam`. + Defaults to ``False``. + .. versionadded:: 2.8 """ @@ -302,7 +304,9 @@ def __init__( ... @overload - def __init__(self, *, mention_total_limit: int, mention_raid_protection_enabled: bool) -> None: + def __init__( + self, *, mention_total_limit: int, mention_raid_protection_enabled: bool = False + ) -> None: ... def __init__( From 3a3fbd27355365553e8c41ca2f6a5c6b7161ebf8 Mon Sep 17 00:00:00 2001 From: Victorsitou <67214928+Victorsitou@users.noreply.github.com> Date: Fri, 5 May 2023 14:27:28 -0400 Subject: [PATCH 11/11] chore: change to 2.9 --- disnake/automod.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disnake/automod.py b/disnake/automod.py index f7a08146c9..0620abdd7c 100644 --- a/disnake/automod.py +++ b/disnake/automod.py @@ -277,7 +277,7 @@ class AutoModTriggerMetadata: Defaults to ``False``. - .. versionadded:: 2.8 + .. versionadded:: 2.9 """ __slots__ = (