| Total Complexity | 2 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # Copyright Pincer 2021-Present |
||
|
|
|||
| 2 | # Full MIT License can be found in `LICENSE` at the project root. |
||
| 3 | |||
| 4 | from __future__ import annotations |
||
| 5 | |||
| 6 | from copy import copy |
||
| 7 | |||
| 8 | from ...utils.api_object import APIObject |
||
| 9 | |||
| 10 | |||
| 11 | class _Component(APIObject): |
||
| 12 | """Represents a message component with attributes that can be modified inline""" |
||
| 13 | |||
| 14 | def with_attrs(self, **kwargs) -> _Component: |
||
| 15 | """ |
||
| 16 | Modifies attributes are returns an object with these attributes. |
||
| 17 | |||
| 18 | .. code-block:: python |
||
| 19 | |||
| 20 | some_button.with_attrs(label="A new label") |
||
| 21 | |||
| 22 | \\*\\*kwargs |
||
| 23 | Attributes to modify and their values. |
||
| 24 | """ |
||
| 25 | copied_obj = copy(self) |
||
| 26 | |||
| 27 | for key, value in kwargs.items(): |
||
| 28 | setattr(copied_obj, key, value) |
||
| 29 | |||
| 30 | return copied_obj |
||
| 31 |