|
28 | 28 | import asyncio |
29 | 29 | import datetime |
30 | 30 | from collections.abc import Sequence |
31 | | -from typing import TYPE_CHECKING, Any, Coroutine, Generic, Union, Unpack, cast |
| 31 | +from typing import TYPE_CHECKING, Any, Coroutine, Generic, cast |
32 | 32 |
|
33 | | -from typing_extensions import TypeVar, TypeVarTuple |
| 33 | +from typing_extensions import TypeVar, TypeVarTuple, Unpack |
34 | 34 |
|
35 | 35 | from . import utils |
36 | 36 | from .channel import PartialMessageable, _threaded_channel_factory |
|
45 | 45 | from .monetization import Entitlement |
46 | 46 | from .object import Object |
47 | 47 | from .permissions import Permissions |
| 48 | +from .role import Role |
48 | 49 | from .user import User |
49 | 50 | from .utils.private import cached_slot_property, delay_task, deprecated, get_as_snowflake |
50 | 51 | from .webhook.async_ import ( |
|
92 | 93 | from .types.interactions import Interaction as InteractionPayload |
93 | 94 | from .types.interactions import InteractionData |
94 | 95 | from .types.interactions import InteractionMetadata as InteractionMetadataPayload |
| 96 | + from .types.interactions import ModalInteraction as ModalInteractionPayload |
95 | 97 | from .types.partial_components import PartialComponent |
96 | 98 |
|
97 | 99 | InteractionChannel = ( |
@@ -664,7 +666,18 @@ def to_dict(self) -> dict[str, Any]: |
664 | 666 |
|
665 | 667 |
|
666 | 668 | class ModalInteraction(Interaction, Generic[Unpack[Components_t]]): |
667 | | - __slots__ = ("_components",) |
| 669 | + __slots__ = ("_components", "users", "attachments") |
| 670 | + |
| 671 | + def __init__(self, *, data: ModalInteractionPayload, state: ConnectionState): |
| 672 | + super().__init__(data=data, state=state) |
| 673 | + resolved = data.get("data", {}).get("resolved", {}) |
| 674 | + self.users: dict[int, User] = {int(user_id): User(state=state, data=user_data) for user_id, user_data in resolved.get("users", {}).items()} |
| 675 | + self.attachments: dict[int, Attachment] = {int(att_id): Attachment(state=state, data=att_data) for att_id, att_data in resolved.get("attachments", {}).items()} |
| 676 | + self.roles: dict[int, Role] = { |
| 677 | + int(role_id): Role(state=state, data=role_data, guild=self.guild) for role_id, role_data in resolved.get("roles", {}).items() |
| 678 | + } |
| 679 | + |
| 680 | + # TODO: When we have better partial objects, add self.channels and self.members |
668 | 681 |
|
669 | 682 | @cached_slot_property("_components") |
670 | 683 | def components(self) -> ComponentsHolder[Unpack[Components_t]]: |
|
0 commit comments