Browse Source

Add Interaction.filesize_limit

pull/10215/head
Leonardo 2 weeks ago
committed by GitHub
parent
commit
ef06d7d9db
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 8
      discord/interactions.py
  2. 1
      discord/types/interactions.py
  3. 2
      tests/test_app_commands_invoke.py

8
discord/interactions.py

@ -154,6 +154,10 @@ class Interaction(Generic[ClientT]):
The context of the interaction. The context of the interaction.
.. versionadded:: 2.4 .. 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, ...] = ( __slots__: Tuple[str, ...] = (
@ -172,7 +176,8 @@ class Interaction(Generic[ClientT]):
'command_failed', 'command_failed',
'entitlement_sku_ids', 'entitlement_sku_ids',
'entitlements', 'entitlements',
"context", 'context',
'filesize_limit',
'_integration_owners', '_integration_owners',
'_permissions', '_permissions',
'_app_permissions', '_app_permissions',
@ -214,6 +219,7 @@ class Interaction(Generic[ClientT]):
self.application_id: int = int(data['application_id']) 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.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.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. # This is not entirely useful currently, unsure how to expose it in a way that it is.
self._integration_owners: Dict[int, Snowflake] = { self._integration_owners: Dict[int, Snowflake] = {
int(k): int(v) for k, v in data.get('authorizing_integration_owners', {}).items() int(k): int(v) for k, v in data.get('authorizing_integration_owners', {}).items()

1
discord/types/interactions.py

@ -233,6 +233,7 @@ class _BaseInteraction(TypedDict):
entitlements: NotRequired[List[Entitlement]] entitlements: NotRequired[List[Entitlement]]
authorizing_integration_owners: Dict[Literal['0', '1'], Snowflake] authorizing_integration_owners: Dict[Literal['0', '1'], Snowflake]
context: NotRequired[InteractionContextType] context: NotRequired[InteractionContextType]
attachment_size_limit: int
class PingInteraction(_BaseInteraction): class PingInteraction(_BaseInteraction):

2
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 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
""" """
from __future__ import annotations from __future__ import annotations
@ -90,6 +91,7 @@ class MockCommandInteraction(discord.Interaction):
"version": 1, "version": 1,
"type": 2, "type": 2,
"data": self._get_command_data(command, self._get_command_options(**options)), "data": self._get_command_data(command, self._get_command_options(**options)),
"attachment_size_limit": 0,
} }
super().__init__(data=data, state=client._connection) super().__init__(data=data, state=client._connection)

Loading…
Cancel
Save