You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: discord_slash/utils/manage_components.py
+15-9
Original file line number
Diff line number
Diff line change
@@ -156,17 +156,21 @@ def create_select_option(
156
156
"""
157
157
Creates an option for select components.
158
158
159
-
.. warning::
160
-
Currently, select components are not available for public use, nor do they have official documentation. The parameters will not be documented at this time.
161
-
162
-
:param label: The label of the option.
163
-
:param value: The value that the bot will recieve when this option is selected.
159
+
:param label: The user-facing name of the option that will be displayed in discord client.
160
+
:param value: The value that the bot will receive when this option is selected.
164
161
:param emoji: The emoji of the option.
165
-
:param description: A description of the option.
162
+
:param description: An additional description of the option.
166
163
:param default: Whether or not this is the default option.
167
164
"""
168
165
emoji=emoji_to_dict(emoji)
169
166
167
+
ifnotlen(label) orlen(label) >25:
168
+
raiseIncorrectFormat("Label length should be between 1 and 25.")
169
+
ifnotlen(value) orlen(value) >100:
170
+
raiseIncorrectFormat("Value length should be between 1 and 100.")
171
+
ifdescriptionisnotNoneandlen(description) >50:
172
+
raiseIncorrectFormat("Description length must be 50 or lower.")
173
+
170
174
return {
171
175
"label": label,
172
176
"value": value,
@@ -186,9 +190,11 @@ def create_select(
186
190
"""
187
191
Creates a select (dropdown) component for use with the ``components`` field. Must be inside an ActionRow to be used (see :meth:`create_actionrow`).
188
192
189
-
190
-
.. warning::
191
-
Currently, select components are not available for public use, nor do they have official documentation. The parameters will not be documented at this time.
193
+
:param options: The choices the user can pick from
194
+
:param custom_id: A custom identifier, like buttons
195
+
:param placeholder: Custom placeholder text if nothing is selected
196
+
:param min_values: The minimum number of items that **must** be chosen
197
+
:param max_values: The maximum number of items that **can** be chosen
192
198
"""
193
199
ifnotlen(options) orlen(options) >25:
194
200
raiseIncorrectFormat("Options length should be between 1 and 25.")
Copy file name to clipboardExpand all lines: docs/components.rst
+25
Original file line number
Diff line number
Diff line change
@@ -99,3 +99,28 @@ How do I know which button was pressed?
99
99
_______________________________________
100
100
101
101
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.
102
+
103
+
What about selects / Dropdowns?
104
+
_______________________________
105
+
106
+
Yep we support those too. You use them much the same as buttons:
107
+
108
+
.. code-block:: python
109
+
110
+
from discord_slash.utils.manage_components import create_select, create_select_option
0 commit comments