Skip to content
This repository was archived by the owner on Dec 18, 2021. It is now read-only.

Commit 9e791c5

Browse files
authored
Merge pull request #94 from TheShubhendra/master
Add disable_components method to Message
2 parents 28742ab + f0e65f8 commit 9e791c5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

discord_components/component.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,15 @@ class ActionRow(Component):
452452
def __init__(self, *args: List[Component]):
453453
self._components = list(args) if args is not None else []
454454

455+
def disable_components(self) -> List[Component]:
456+
def disable(component: Component):
457+
component.disabled = True
458+
return component
459+
460+
disabled_row = list(map(disable, self._components))
461+
self._components = disabled_row
462+
return disabled_row
463+
455464
def __list__(self) -> List[Component]:
456465
return self.components
457466

discord_components/dpy_overrides.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ def get_component(self, custom_id: str) -> Optional[Component]:
3939
if component.custom_id == custom_id:
4040
return component
4141

42+
async def disable_components(self) -> None:
43+
disabled_components = [row.disable_components() for row in self.components]
44+
await self.edit(
45+
components=disabled_components,
46+
)
47+
4248
async def edit(
4349
self,
4450
content: Optional[str] = None,

0 commit comments

Comments
 (0)