Skip to content

Add Interaction.filesize_limit #10159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...] = (
Expand All @@ -172,7 +176,8 @@ class Interaction(Generic[ClientT]):
'command_failed',
'entitlement_sku_ids',
'entitlements',
"context",
'context',
'filesize_limit',
'_integration_owners',
'_permissions',
'_app_permissions',
Expand Down Expand Up @@ -214,6 +219,7 @@ def _from_data(self, data: InteractionPayload):
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()
Expand Down
1 change: 1 addition & 0 deletions discord/types/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_app_commands_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""

from __future__ import annotations


Expand Down Expand Up @@ -90,6 +91,7 @@ def __init__(
"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)

Expand Down
Loading