ActionRow.to_dict()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from __future__ import annotations
5
6
from typing import TYPE_CHECKING
7
8
from ._component import _Component
9
from ...objects.app.command import InteractableStructure
10
11
from ...utils.api_object import APIObject
12
13
if TYPE_CHECKING:
14
    from typing import Dict
15
16
17
class ActionRow(APIObject):
18
    """Represents an Action Row
19
20
    Parameters
21
    ----------
22
    \\*components : :class:`~pincer.objects.message.component.MessageComponent`
23
        :class:`~pincer.objects.message.component.MessageComponent`,
24
        :class:`~pincer.objects.message.button.Button`, or
25
        :class:`~pincer.objects.message.select_menu.SelectMenu`
26
    """
27
28
    def __init__(self, *components: InteractableStructure[_Component]):
29
        self.components = components
30
31
    def to_dict(self) -> Dict:
32
        return {
33
            "type": 1,
34
            "components": [
35
                component.metadata.to_dict() for component in self.components
36
            ],
37
        }
38