Skip to content

Commit 71758e6

Browse files
authored
Component Doc Changes (#215)
* added note about datatype * Minor doc changes for formatting, grammar, and clarity
1 parent 6e0d077 commit 71758e6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

discord_slash/utils/manage_components.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ def create_actionrow(*components: dict) -> dict:
2828

2929
def spread_to_rows(*components, max_in_row=5) -> typing.List[dict]:
3030
"""
31-
Generates list of actionsrows from given components.
31+
A helper function that spreads your components into ``actionrows`` of a set size
3232
3333
:param components: Components dicts (buttons or selects or existing actionrows) to spread. Use `None` to explicitly start a new row.
3434
:type components: dict
3535
:param max_in_row: Maximum number of elements in each row.
3636
:type max_in_row: int
3737
:return: list
38+
39+
.. note:: An action_row can only have a maximum of 5 items in it
3840
"""
3941
if not components or len(components) > 25:
4042
raise IncorrectFormat("Number of components should be between 1 and 25.")
@@ -94,7 +96,7 @@ def create_button(
9496
disabled: bool = False,
9597
) -> dict:
9698
"""
97-
Creates a button component for use with the ``components`` field. Must be inside an ActionRow to be used (see :meth:`create_actionrow`).
99+
Creates a button component for use with the ``components`` field. Must be used within an ``actionRow`` to be used (see :meth:`create_actionrow`).
98100
99101
.. note::
100102
At least a label or emoji is required for a button. You can have both, but not neither of them.
@@ -152,6 +154,9 @@ def create_select_option(
152154
"""
153155
Creates an option for select components.
154156
157+
.. warning::
158+
Currently, select components are not available for public use, nor do they have official documentation. The parameters will not be documented at this time.
159+
155160
:param label: The label of the option.
156161
:param value: The value that the bot will recieve when this option is selected.
157162
:param emoji: The emoji of the option.
@@ -179,8 +184,9 @@ def create_select(
179184
"""
180185
Creates a select (dropdown) component for use with the ``components`` field. Must be inside an ActionRow to be used (see :meth:`create_actionrow`).
181186
187+
182188
.. warning::
183-
Currently, select components are not available for public use, nor have official documentation. The parameters will not be documented at this time.
189+
Currently, select components are not available for public use, nor do they have official documentation. The parameters will not be documented at this time.
184190
"""
185191
if not len(options) or len(options) > 25:
186192
raise IncorrectFormat("Options length should be between 1 and 25.")
@@ -197,9 +203,9 @@ def create_select(
197203

198204
def get_components_ids(component: typing.Union[str, dict, list]) -> typing.Iterator[str]:
199205
"""
200-
Returns generator with 'custom_id' of component or list of components.
206+
Returns generator with the ``custom_id`` of a component or list of components.
201207
202-
:param component: Custom ID or component dict (actionrow or button) or list of previous two.
208+
:param component: Custom ID or component dict (actionrow or button) or list of the two.
203209
:returns: typing.Iterator[str]
204210
"""
205211

@@ -222,7 +228,7 @@ def get_components_ids(component: typing.Union[str, dict, list]) -> typing.Itera
222228

223229
def get_messages_ids(message: typing.Union[int, discord.Message, list]) -> typing.Iterator[int]:
224230
"""
225-
Returns generator with id of message or list messages.
231+
Returns generator with the ``id`` of message or list messages.
226232
227233
:param message: message ID or message object or list of previous two.
228234
:returns: typing.Iterator[int]
@@ -249,6 +255,7 @@ async def wait_for_component(
249255
) -> ComponentContext:
250256
"""
251257
Helper function - wrapper around 'client.wait_for("component", ...)'
258+
252259
Waits for a component interaction. Only accepts interactions based on the custom ID of the component or/and message ID, and optionally a check function.
253260
254261
:param client: The client/bot object.

docs/components.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ Well lucky for you, you don't have to. You can either respond silently, with a t
7575
How do i know which button was pressed?
7676
_______________________________________
7777

78-
Each button gets a ``custom_id``, this is a unique identifier of which button is being pressed. You can specify what the ID is when you define your button, if you don't; a random one will be generated. When handling the event, simply check the custom_id, and handle accordingly.
78+
Each button gets a ``custom_id`` (which is always a string), this is a unique identifier of which button is being pressed. You can specify what the ID is when you define your button, if you don't; a random one will be generated. When handling the event, simply check the custom_id, and handle accordingly.

0 commit comments

Comments
 (0)