Skip to content

Commit 54464ec

Browse files
GeomKidpre-commit-ci[bot]Toricane
authored
fix: ComponentContext.label not updated to reflect component models (#1096)
* Update misc.py * ci: correct from checks. * Update context.py * Update context.py * fix precommit * Revert changes to misc.py * revert unwanted changes * ci: correct from checks. * revert unwanted changes again * Update context.py * Update interactions/client/context.py Co-authored-by: Toricane <73972068+Toricane@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Toricane <73972068+Toricane@users.noreply.github.com>
1 parent 27d8233 commit 54464ec

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

interactions/client/context.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from ..base import get_logger
1313
from ..utils.attrs_utils import ClientSerializerMixin, convert_int, define, field
1414
from ..utils.missing import MISSING
15-
from .enums import InteractionCallbackType, InteractionType
15+
from .enums import ComponentType, InteractionCallbackType, InteractionType
1616
from .models.command import Choice
1717
from .models.component import ActionRow, Button, Modal, SelectMenu, _build_components
1818
from .models.misc import InteractionData
@@ -744,7 +744,17 @@ def custom_id(self) -> Optional[str]:
744744

745745
@property
746746
def label(self) -> Optional[str]:
747+
"""
748+
The label of the interacted button.
749+
:rtype: Optional[str]
750+
"""
751+
if not self.data.component_type == ComponentType.BUTTON:
752+
return
753+
if self.message is None:
754+
return
755+
if self.message.components is None:
756+
return
747757
for action_row in self.message.components:
748-
for component in action_row["components"]:
749-
if component["custom_id"] == self.custom_id and component["type"] == 2:
750-
return component.get("label")
758+
for component in action_row.components:
759+
if component.custom_id == self.custom_id:
760+
return component.label

0 commit comments

Comments
 (0)