Skip to content

Commit 7c00cff

Browse files
authored
feat: add component property to ComponentContext (#1371)
* feat: add component to property of ComponentContext * format: formatting run through * Fix Typehints and docs * fix Grammar Error for docs
1 parent 800cdc1 commit 7c00cff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

interactions/models/internal/context.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,16 @@ async def edit_origin(
780780
self.message_id = message.id
781781
return message
782782

783+
@property
784+
def component(self) -> typing.Optional[BaseComponent]:
785+
"""The component that was interacted with."""
786+
if self.message is None or self.message.components is None:
787+
return None
788+
for action_row in self.message.components:
789+
for component in action_row.components:
790+
if component.custom_id == self.custom_id:
791+
return component
792+
783793

784794
class ModalContext(InteractionContext):
785795
responses: dict[str, str]

0 commit comments

Comments
 (0)