From ec81001a949cd4868eb10a0391b94858b5398ec1 Mon Sep 17 00:00:00 2001 From: hich4t Date: Mon, 4 Aug 2025 01:59:57 +0300 Subject: [PATCH 1/8] added attachment_size_limit: NotRequired[int] Signed-off-by: hich4t --- discord/types/interactions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/discord/types/interactions.py b/discord/types/interactions.py index 37904a580a..8b41cb8844 100644 --- a/discord/types/interactions.py +++ b/discord/types/interactions.py @@ -215,6 +215,7 @@ class Interaction(TypedDict): locale: NotRequired[str] guild_locale: NotRequired[str] app_permissions: NotRequired[Permissions] + attachment_size_limit: NotRequired[int] id: Snowflake application_id: Snowflake type: InteractionType From 37c3e839f02a979025f5558de98b80889a7b316f Mon Sep 17 00:00:00 2001 From: hich4t Date: Mon, 4 Aug 2025 03:33:14 +0300 Subject: [PATCH 2/8] added attachment_size_limit: NotRequired[int] Signed-off-by: hich4t --- discord/interactions.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/discord/interactions.py b/discord/interactions.py index 0e9084468d..a2de915824 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -164,6 +164,10 @@ class Interaction: modal: Optional[:class:`Modal`] The modal that this interaction belongs to. + .. versionadded:: 2.7 + attachment_size_limit: Optional[:class:`int`] + The limit size of attachment. + .. versionadded:: 2.7 """ @@ -188,6 +192,7 @@ class Interaction: "command", "view", "modal", + "attachment_size_limit", "_channel_data", "_message_data", "_guild_data", @@ -243,6 +248,7 @@ def _from_data(self, data: InteractionPayload): self.command: ApplicationCommand | None = None self.view: View | None = None self.modal: Modal | None = None + self.attachment_size_limit: int | None = data.get("attachment_size_limit") self.message: Message | None = None self.channel = None From b00c3e18f2696e5fd7c5735d8d6db17e45016708 Mon Sep 17 00:00:00 2001 From: hich4t Date: Mon, 4 Aug 2025 22:15:32 +0300 Subject: [PATCH 3/8] changed "The limit size of attachment." to "The attachment size limit." Signed-off-by: hich4t --- discord/interactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/interactions.py b/discord/interactions.py index a2de915824..fc9c7aabf6 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -166,7 +166,7 @@ class Interaction: .. versionadded:: 2.7 attachment_size_limit: Optional[:class:`int`] - The limit size of attachment. + The attachment size limit. .. versionadded:: 2.7 """ From 554ecb1c352295e6d9c0dda28a33e4ab97caff59 Mon Sep 17 00:00:00 2001 From: hich4t Date: Tue, 5 Aug 2025 00:51:53 +0300 Subject: [PATCH 4/8] =?UTF-8?q?chore:=20=F0=9F=93=9D=20Update=20CHANGELOG.?= =?UTF-8?q?md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: hich4t --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 718642108d..7796855813 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2817](https://github.com/Pycord-Development/pycord/pull/2817)) - Added role gradients support with `Role.colours` and the `RoleColours` class. ([#2818](https://github.com/Pycord-Development/pycord/pull/2818)) +- Added `discord.Interaction.attachment_size_limit`. + ([#2854](https://github.com/Pycord-Development/pycord/pull/2854)) ### Fixed From 88da798fd32313b63bc62f93966c14439e8e6c09 Mon Sep 17 00:00:00 2001 From: hich4t Date: Tue, 5 Aug 2025 01:27:41 +0300 Subject: [PATCH 5/8] feat: add ApplicationContext.attachment_size_limit property Signed-off-by: hich4t --- discord/commands/context.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/discord/commands/context.py b/discord/commands/context.py index e066bd32bc..a4c71748a9 100644 --- a/discord/commands/context.py +++ b/discord/commands/context.py @@ -268,6 +268,13 @@ def unselected_options(self) -> list[Option] | None: return self.command.options # type: ignore return None + @cached_property + def attachment_size_limit(self) -> int | None: + """Returns the attachment size limit associated with this context's command. + Shorthand for :attr:`.Interaction.attachment_size_limit`. + """ + return self.interaction.attachment_size_limit + @property @discord.utils.copy_doc(InteractionResponse.send_modal) def send_modal(self) -> Callable[..., Awaitable[Interaction]]: From 122541e32571f94e74be3d31fdbfce68fd8822b9 Mon Sep 17 00:00:00 2001 From: hich4t Date: Tue, 5 Aug 2025 19:06:04 +0300 Subject: [PATCH 6/8] Update discord/commands/context.py Co-authored-by: Paillat Signed-off-by: hich4t --- discord/commands/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/commands/context.py b/discord/commands/context.py index a4c71748a9..029ba17202 100644 --- a/discord/commands/context.py +++ b/discord/commands/context.py @@ -270,7 +270,7 @@ def unselected_options(self) -> list[Option] | None: @cached_property def attachment_size_limit(self) -> int | None: - """Returns the attachment size limit associated with this context's command. + """Returns the attachment size limit associated with this context's interaction. Shorthand for :attr:`.Interaction.attachment_size_limit`. """ return self.interaction.attachment_size_limit From d90e468cbe39e40e2c0362a955c4c13b6eea1b57 Mon Sep 17 00:00:00 2001 From: hich4t Date: Tue, 5 Aug 2025 19:06:22 +0300 Subject: [PATCH 7/8] Update CHANGELOG.md Co-authored-by: Paillat Signed-off-by: hich4t --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7796855813..7d76398448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,7 +67,7 @@ These changes are available on the `master` branch, but have not yet been releas ([#2817](https://github.com/Pycord-Development/pycord/pull/2817)) - Added role gradients support with `Role.colours` and the `RoleColours` class. ([#2818](https://github.com/Pycord-Development/pycord/pull/2818)) -- Added `discord.Interaction.attachment_size_limit`. +- Added `Interaction.attachment_size_limit`. ([#2854](https://github.com/Pycord-Development/pycord/pull/2854)) ### Fixed From af22a6b1ceaacbbd711642181934b6f6f7d5f43b Mon Sep 17 00:00:00 2001 From: hich4t Date: Tue, 5 Aug 2025 19:45:56 +0300 Subject: [PATCH 8/8] fix: change 'attachment_size_limit' from optional to required --- discord/commands/context.py | 2 +- discord/interactions.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/discord/commands/context.py b/discord/commands/context.py index 029ba17202..01164b1189 100644 --- a/discord/commands/context.py +++ b/discord/commands/context.py @@ -269,7 +269,7 @@ def unselected_options(self) -> list[Option] | None: return None @cached_property - def attachment_size_limit(self) -> int | None: + def attachment_size_limit(self) -> int: """Returns the attachment size limit associated with this context's interaction. Shorthand for :attr:`.Interaction.attachment_size_limit`. """ diff --git a/discord/interactions.py b/discord/interactions.py index fc9c7aabf6..888ed7658f 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -165,7 +165,7 @@ class Interaction: The modal that this interaction belongs to. .. versionadded:: 2.7 - attachment_size_limit: Optional[:class:`int`] + attachment_size_limit: :class:`int` The attachment size limit. .. versionadded:: 2.7 @@ -248,7 +248,7 @@ def _from_data(self, data: InteractionPayload): self.command: ApplicationCommand | None = None self.view: View | None = None self.modal: Modal | None = None - self.attachment_size_limit: int | None = data.get("attachment_size_limit") + self.attachment_size_limit: int = data.get("attachment_size_limit") self.message: Message | None = None self.channel = None