Skip to content

feat: added Interaction.attachment_size_limit #2854

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

Merged
merged 9 commits into from
Aug 5, 2025
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `Interaction.attachment_size_limit`.
([#2854](https://github.com/Pycord-Development/pycord/pull/2854))

### Fixed

Expand Down
7 changes: 7 additions & 0 deletions discord/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""Returns the attachment size limit associated with this context's interaction.
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]]:
Expand Down
6 changes: 6 additions & 0 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ class Interaction:
modal: Optional[:class:`Modal`]
The modal that this interaction belongs to.

.. versionadded:: 2.7
attachment_size_limit: :class:`int`
The attachment size limit.

.. versionadded:: 2.7
"""

Expand All @@ -188,6 +192,7 @@ class Interaction:
"command",
"view",
"modal",
"attachment_size_limit",
"_channel_data",
"_message_data",
"_guild_data",
Expand Down Expand Up @@ -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 = data.get("attachment_size_limit")

self.message: Message | None = None
self.channel = None
Expand Down
1 change: 1 addition & 0 deletions discord/types/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading