From ef06d7d9db2b868c57f45fe1252d055490ad31a9 Mon Sep 17 00:00:00 2001 From: Leonardo Date: Fri, 20 Jun 2025 20:30:37 +0200 Subject: [PATCH] Add Interaction.filesize_limit --- discord/interactions.py | 8 +++++++- discord/types/interactions.py | 1 + tests/test_app_commands_invoke.py | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/discord/interactions.py b/discord/interactions.py index a983d8ab0..cb9a21e88 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -154,6 +154,10 @@ class Interaction(Generic[ClientT]): The context of the interaction. .. versionadded:: 2.4 + filesize_limit: int + The maximum number of bytes a file can have when responding to this interaction. + + .. versionadded:: 2.6 """ __slots__: Tuple[str, ...] = ( @@ -172,7 +176,8 @@ class Interaction(Generic[ClientT]): 'command_failed', 'entitlement_sku_ids', 'entitlements', - "context", + 'context', + 'filesize_limit', '_integration_owners', '_permissions', '_app_permissions', @@ -214,6 +219,7 @@ class Interaction(Generic[ClientT]): self.application_id: int = int(data['application_id']) self.entitlement_sku_ids: List[int] = [int(x) for x in data.get('entitlement_skus', []) or []] self.entitlements: List[Entitlement] = [Entitlement(self._state, x) for x in data.get('entitlements', [])] + self.filesize_limit: int = data['attachment_size_limit'] # This is not entirely useful currently, unsure how to expose it in a way that it is. self._integration_owners: Dict[int, Snowflake] = { int(k): int(v) for k, v in data.get('authorizing_integration_owners', {}).items() diff --git a/discord/types/interactions.py b/discord/types/interactions.py index 3f3516c3a..3e814b49d 100644 --- a/discord/types/interactions.py +++ b/discord/types/interactions.py @@ -233,6 +233,7 @@ class _BaseInteraction(TypedDict): entitlements: NotRequired[List[Entitlement]] authorizing_integration_owners: Dict[Literal['0', '1'], Snowflake] context: NotRequired[InteractionContextType] + attachment_size_limit: int class PingInteraction(_BaseInteraction): diff --git a/tests/test_app_commands_invoke.py b/tests/test_app_commands_invoke.py index 35915c19b..6366096f0 100644 --- a/tests/test_app_commands_invoke.py +++ b/tests/test_app_commands_invoke.py @@ -21,6 +21,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + from __future__ import annotations @@ -90,6 +91,7 @@ class MockCommandInteraction(discord.Interaction): "version": 1, "type": 2, "data": self._get_command_data(command, self._get_command_options(**options)), + "attachment_size_limit": 0, } super().__init__(data=data, state=client._connection)