Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 interactions/api/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ def check_sub_auto(option: dict) -> tuple:
)
elif data["type"] == InteractionType.MESSAGE_COMPONENT:
_name = f"component_{context.data.custom_id}"
if context.data._json.get("values"):
_args.append(context.data.values)
Comment on lines +317 to +318
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good to me,
but I want to know the reason behind the add values in message component detail, over simply just using context object as how it was in v3's callbacks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in the callback function it will be much easier to immediately receive the selected value than to request it from nowhere (I, for example, did not immediately understand that the value can be obtained from the context).

elif data["type"] == InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE:
_name = f"autocomplete_{context.data.id}"
if context.data._json.get("options"):
Expand Down
2 changes: 2 additions & 0 deletions interactions/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ async def send(
for component in components.components
]
elif isinstance(components, (Button, SelectMenu)):
if isinstance(components, SelectMenu):
components._json["options"] = [option._json for option in components.options]
_components[0]["components"] = (
[components._json]
if components._json.get("custom_id") or components._json.get("url")
Expand Down
12 changes: 8 additions & 4 deletions interactions/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)
self.type = ComponentType.SELECT
self.options = (
SelectOption(**option)
if not isinstance(option, SelectOption)
else self._json.get("options")
for option in self.options
[
SelectOption(**option._json)
if isinstance(option, SelectOption)
else SelectOption(**option)
for option in self.options
]
if self._json.get("options")
else None
)
self._json.update({"type": self.type.value})

Expand Down