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
This basic example shows how to easily integrate buttons into your commands. Buttons are not limited to
104
+
slash commands and may be used in regular discord.py commands as well.
105
+
(This example refers off of [slash commands.](#slash-commands))
106
+
107
+
```py
108
+
from discord_slash.utils.manage_components import create_button, create_actionrow
109
+
from discord_slash.model import ButtonStyle
110
+
111
+
buttons = [
112
+
create_button(style=ButtonStyle.green, label="A green button"),
113
+
create_button(style=ButtonStyle.blue, label="A blue button")
114
+
]
115
+
action_row = create_actionrow(*buttons)
116
+
117
+
await ctx.send(components=[action_row])
118
+
```
119
+
120
+
### Advanced
121
+
For more advanced use, please refer to our official documentation on [buttons here.](https://discord-py-slash-command.readthedocs.io/en/latest/components.html#responding-to-interactions)
122
+
123
+
## Selects
124
+
This basic example shows how to add selects into our bot. Selects offer the same accessibility as buttons do
125
+
in premise of limitations.
126
+
(This exmaple refers off of [slash commands.](#slash-commands))
127
+
128
+
```py
129
+
from discord_slash.utils.manage_components import create_select, create_select_option, create_actionrow
min_values=1, # the minimum number of options a user must select
139
+
max_values=2# the maximum number of options a user can select
140
+
)
141
+
action_row = create_actionrow(select)
142
+
143
+
await ctx.send(components=[action_row])
144
+
```
145
+
146
+
### Advanced
147
+
For more advanced use, please refer to our official documentation on [selects here.](https://discord-py-slash-command.readthedocs.io/en/latest/components.html#what-about-selects-dropdowns)
148
+
81
149
--------
82
-
- This library is based on gateway event. If you are looking for webserver based, have a look at this:
150
+
151
+
- The discord-interactions library is based off of API gateway events. If you are looking for a library webserver-based, please consider:
Copy file name to clipboardExpand all lines: docs/components.rst
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,11 +117,11 @@ Each button gets a ``custom_id`` (which is always a string), this is a unique id
117
117
What about selects / Dropdowns?
118
118
_______________________________
119
119
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!
121
121
122
122
.. code-block:: python
123
123
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
125
125
126
126
select = create_select(
127
127
options=[# the options in your dropdown
@@ -133,8 +133,10 @@ Yep we support those too. You use them much the same as buttons:
133
133
min_values=1, # the minimum number of options a user must select
134
134
max_values=2, # the maximum number of options a user can select
135
135
)
136
+
137
+
await ctx.send("test", components=[create_actionrow(select)]) # like action row with buttons but without * in front of the variable
136
138
137
139
@bot.event
138
140
asyncdefon_component(ctx: ComponentContext):
139
141
# ctx.selected_options is a list of all the values the user selected
0 commit comments