Skip to content
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

feat: implement ctx.custom_id and ctx.label properties #484

Merged
merged 3 commits into from Feb 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions interactions/context.py
Expand Up @@ -769,6 +769,17 @@ def __init__(self, **kwargs) -> None:
self.responded = False # remind components that it was not responded to.
self.deferred = False # remind components they not have been deferred

@property
def custom_id(self):
return self.data.custom_id

@property
def label(self):
for action_row in self.message.components:
for component in action_row["components"]:
if component["custom_id"] == self.custom_id and component["type"] == 2:
return component.get("label")

async def defer(
self, ephemeral: Optional[bool] = False, edit_origin: Optional[bool] = False
) -> None:
Expand Down