Skip to content

Commit 38bbde4

Browse files
How to send selects (#246)
* How to send selects The example of how to create and react to a select did not show how to send a select in the first place. I added an extra line showing how to send a select. * Fix example and show limits Fixed example since you can't send an empty message so you need content, and added the limits to selects. * Change wording Changes wording, replacing "totalling 125 options:" with "but each select can have up to 25 options in it!" Co-authored-by: LordOfPolls <22540825+LordOfPolls@users.noreply.github.com> Co-authored-by: LordOfPolls <22540825+LordOfPolls@users.noreply.github.com>
1 parent fd61a8e commit 38bbde4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/components.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ Each button gets a ``custom_id`` (which is always a string), this is a unique id
117117
What about selects / Dropdowns?
118118
_______________________________
119119

120-
Yep we support those too. You use them much the same as buttons:
120+
Yep we support those too. You use them much the same as buttons. You can only have 1 select per action row, but each select can have up to 25 options in it!
121121

122122
.. code-block:: python
123123
124-
from discord_slash.utils.manage_components import create_select, create_select_option
124+
from discord_slash.utils.manage_components import create_select, create_select_option, create_actionrow
125125
126126
select = create_select(
127127
options=[# the options in your dropdown
@@ -133,8 +133,10 @@ Yep we support those too. You use them much the same as buttons:
133133
min_values=1, # the minimum number of options a user must select
134134
max_values=2, # the maximum number of options a user can select
135135
)
136+
137+
await ctx.send("test", components=[create_actionrow(select)]) # like action row with buttons but without * in front of the variable
136138
137139
@bot.event
138140
async def on_component(ctx: ComponentContext):
139141
# ctx.selected_options is a list of all the values the user selected
140-
await ctx.send(content=f"You selected {ctx.selected_options}")
142+
await ctx.send(content=f"You selected {ctx.selected_options}")

0 commit comments

Comments
 (0)