From a8ce1257ab72905f994647943f001cd0476695cd Mon Sep 17 00:00:00 2001 From: UK <41271523+NeloBlivion@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:39:55 +0100 Subject: [PATCH 1/4] feat: Add custom_message to AutoModActionMetadata and fix TypeError on AutoModRule (#2029) * Automod fixes and additions * style(pre-commit): auto fixes from pre-commit.com hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- discord/automod.py | 19 ++++++++++++++++++- discord/types/automod.py | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/discord/automod.py b/discord/automod.py index 5f091d0f65..2d6b5244da 100644 --- a/discord/automod.py +++ b/discord/automod.py @@ -76,6 +76,10 @@ class AutoModActionMetadata: timeout_duration: :class:`datetime.timedelta` How long the member that triggered the action should be timed out for. Only for actions of type :attr:`AutoModActionType.timeout`. + custom_message: :class:`str` + An additional message shown to members when their message is blocked. + Maximum 150 characters. + Only for actions of type :attr:`AutoModActionType.block_message`. """ # maybe add a table of action types and attributes? @@ -83,13 +87,18 @@ class AutoModActionMetadata: __slots__ = ( "channel_id", "timeout_duration", + "custom_message", ) def __init__( - self, channel_id: int = MISSING, timeout_duration: timedelta = MISSING + self, + channel_id: int = MISSING, + timeout_duration: timedelta = MISSING, + custom_message: str = MISSING, ): self.channel_id: int = channel_id self.timeout_duration: timedelta = timeout_duration + self.custom_message: str = custom_message def to_dict(self) -> dict: data = {} @@ -100,6 +109,9 @@ def to_dict(self) -> dict: if self.timeout_duration is not MISSING: data["duration_seconds"] = self.timeout_duration.total_seconds() + if self.custom_message is not MISSING: + data["custom_message"] = self.custom_message + return data @classmethod @@ -113,12 +125,16 @@ def from_dict(cls, data: AutoModActionMetadataPayload): # might need an explicit int cast kwargs["timeout_duration"] = timedelta(seconds=duration_seconds) + if (custom_message := data.get("custom_message")) is not None: + kwargs["custom_message"] = custom_message + return cls(**kwargs) def __repr__(self) -> str: repr_attrs = ( "channel_id", "timeout_duration", + "custom_message", ) inner = [] @@ -352,6 +368,7 @@ class AutoModRule(Hashable): """ __slots__ = ( + "__dict__", "_state", "id", "guild_id", diff --git a/discord/types/automod.py b/discord/types/automod.py index 4632c8d8c4..4f13b46ae0 100644 --- a/discord/types/automod.py +++ b/discord/types/automod.py @@ -47,6 +47,7 @@ class AutoModTriggerMetadata(TypedDict, total=False): class AutoModActionMetadata(TypedDict, total=False): channel_id: Snowflake duration_seconds: int + custom_message: str class AutoModAction(TypedDict): From 588cc9e7e68b0723897e5ddb088b13f701e83f93 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Tue, 25 Apr 2023 16:54:10 +0200 Subject: [PATCH 2/4] docs(changelog): add missing changelog (#2031) chore(changelog): add missing changelog Signed-off-by: Lala Sabathil --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e65373326..1f83c577f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#1983](https://github.com/Pycord-Development/pycord/pull/1983)) - Added new `application_auto_moderation_rule_create_badge` to `ApplicationFlags`. ([#1992](https://github.com/Pycord-Development/pycord/pull/1992)) +- Added `custom_message` to AutoModActionMetadata. +- ([#2029](https://github.com/Pycord-Development/pycord/pull/2029)) ### Changed @@ -63,6 +65,8 @@ These changes are available on the `master` branch, but have not yet been releas working. ([#1999](https://github.com/Pycord-Development/pycord/pull/1999)) - Fixed `TypeError` being raised when passing `name` argument to bridge groups. ([#2000](https://github.com/Pycord-Development/pycord/pull/2000)) +- Fixed `TypeError` in AutoModRule. +- ([#2029](https://github.com/Pycord-Development/pycord/pull/2029)) ## [2.4.1] - 2023-03-20 From b84a51990f4ce9158b459a1ae12fc1620e227904 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 15:08:36 +0000 Subject: [PATCH 3/4] chore(deps-dev): Update pylint requirement from ~=2.17.2 to ~=2.17.3 (#2027) Updates the requirements on [pylint](https://github.com/PyCQA/pylint) to permit the latest version. - [Release notes](https://github.com/PyCQA/pylint/releases) - [Commits](https://github.com/PyCQA/pylint/compare/v2.17.2...v2.17.3) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements/dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 696ec91da3..a7f2058db2 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,5 +1,5 @@ -r _.txt -pylint~=2.17.2 +pylint~=2.17.3 pytest~=7.3.1 pytest-asyncio~=0.21.0 # pytest-order~=1.0.1 From 3847a8cddf0b9355379c1d10e7216dd7ea14b6d9 Mon Sep 17 00:00:00 2001 From: JustaSqu1d <89910983+JustaSqu1d@users.noreply.github.com> Date: Tue, 25 Apr 2023 08:16:46 -0700 Subject: [PATCH 4/4] docs: add a link to guild features (#2028) Co-authored-by: Lala Sabathil --- discord/guild.py | 46 ++-------------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/discord/guild.py b/discord/guild.py index a84f0d2eba..718164aa8e 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -202,50 +202,8 @@ class Guild(Hashable): The guild's notification settings. features: List[:class:`str`] A list of features that the guild has. The features that a guild can have are - subject to arbitrary change by Discord. - - They are currently as follows: - - - ``ANIMATED_BANNER``: Guild can upload an animated banner. - - ``ANIMATED_ICON``: Guild can upload an animated icon. - - ``APPLICATION_COMMAND_PERMISSIONS_V2``: Guild is using the old command permissions behavior. - - ``AUTO_MODERATION``: Guild has enabled the auto moderation system. - - ``BANNER``: Guild can upload and use a banner. (i.e. :attr:`.banner`) - - ``CHANNEL_BANNER``: Guild can upload and use a channel banners. - - ``COMMERCE``: Guild can sell things using store channels, which have now been removed. - - ``COMMUNITY``: Guild is a community server. - - ``DEVELOPER_SUPPORT_SERVER``: Guild has been set as a support server on the App Directory. - - ``DISCOVERABLE``: Guild shows up in Server Discovery. - - ``FEATURABLE``: Guild can be featured in the Server Directory. - - ``HAS_DIRECTORY_ENTRY``: Unknown. - - ``HUB``: Hubs contain a directory channel that let you find school-related, student-run servers for your school or university. - - ``INTERNAL_EMPLOYEE_ONLY``: Indicates that only users with the staff badge can join the guild. - - ``INVITES_DISABLED``: Guild Invites are disabled. - - ``INVITE_SPLASH``: Guild's invite page can have a special splash. - - ``LINKED_TO_HUB``: 'Guild is linked to a hub. - - ``MEMBER_PROFILES``: Unknown. - - ``MEMBER_VERIFICATION_GATE_ENABLED``: Guild has Membership Screening enabled. - - ``MONETIZATION_ENABLED``: Guild has enabled monetization. - - ``MORE_EMOJI``: Guild has increased custom emoji slots. - - ``MORE_STICKERS``: Guild has increased custom sticker slots. - - ``NEWS``: Guild can create news channels. - - ``NEW_THREAD_PERMISSIONS``: Guild has new thread permissions. - - ``PARTNERED``: Guild is a partnered server. - - ``PREMIUM_TIER_3_OVERRIDE``: Forces the server to server boosting level 3 (specifically created by Discord Staff Member "Jethro" for their personal server). - - ``PREVIEW_ENABLED``: Guild can be viewed before being accepted via Membership Screening. - - ``ROLE_ICONS``: Guild can set an image or emoji as a role icon. - - ``ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE``: Role subscriptions are available for purchasing. - - ``ROLE_SUBSCRIPTIONS_ENABLED``: Guild is able to view and manage role subscriptions. - - ``SEVEN_DAY_THREAD_ARCHIVE``: Users can set the thread archive time to 7 days. - - ``TEXT_IN_VOICE_ENABLED``: Guild has a chat button inside voice channels that opens a dedicated text channel in a sidebar similar to thread view. - - ``THREADS_ENABLED_TESTING``: Used by bot developers to test their bots with threads in guilds with 5 or fewer members and a bot. Also gives the premium thread features. - - ``THREE_DAY_THREAD_ARCHIVE``: Users can set the thread archive time to 3 days. - - ``TICKETED_EVENTS_ENABLED``: Guild has enabled ticketed events. - - ``VANITY_URL``: Guild can have a vanity invite URL (e.g. discord.gg/discord-api). - - ``VERIFIED``: Guild is a verified server. - - ``VIP_REGIONS``: Guild has VIP voice regions. - - ``WELCOME_SCREEN_ENABLED``: Guild has enabled the welcome screen. - + subject to arbitrary change by Discord. You can find a catalog of guild features + `here `_. premium_tier: :class:`int` The premium tier for this guild. Corresponds to "Nitro Server" in the official UI. The number goes from 0 to 3 inclusive.