Skip to content

Commit ed8ae12

Browse files
committed
Merge remote-tracking branch 'origin/dev' into dev
2 parents d944659 + f5215c7 commit ed8ae12

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

guide/docs/interactions/buttons.mdx

+11-14
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ Components allow users to interact with your bot through interactive UI elements
1818
<div slot="actions">
1919
<DiscordButtons>
2020
<DiscordButton type="success">Yes</DiscordButton>
21+
</DiscordButtons>
22+
<DiscordButtons>
2123
<DiscordButton type="danger">No</DiscordButton>
2224
</DiscordButtons>
2325
</div>
2426
</DiscordMessage>
2527
</DiscordMessages>
2628
<br />
2729

28-
The code for this command is given below.
30+
We will now demonstrate the two primary ways you can achieve the button layout above
2931

30-
```python title="buttons.py"
32+
```python title="buttons.py -- Low Level Implementation"
3133
# At the top of the file.
3234
import disnake
3335
from disnake.ext import commands
@@ -38,27 +40,25 @@ async def buttons(inter: disnake.ApplicationCommandInteraction):
3840
await inter.response.send_message(
3941
"Need help?",
4042
components=[
41-
disnake.ui.Button(label="Yes", style=disnake.ButtonStyle.success, custom_id="yes"),
42-
disnake.ui.Button(label="No", style=disnake.ButtonStyle.danger, custom_id="no"),
43+
disnake.ui.Button(label="Yes", style=disnake.ButtonStyle.success, custom_id="help_yes"),
44+
disnake.ui.Button(label="No", style=disnake.ButtonStyle.danger, custom_id="help_no"),
4345
],
4446
)
4547

4648

4749
@bot.listen("on_button_click")
4850
async def help_listener(inter: disnake.MessageInteraction):
49-
if inter.component.custom_id not in ["yes", "no"]:
51+
if not inter.component.custom_id.startswith("help"):
5052
# We filter out any other button presses except
5153
# the components we wish to process.
5254
return
5355

54-
if inter.component.custom_id == "yes":
56+
if inter.component.custom_id == "help_yes":
5557
await inter.response.send_message("Contact us at https://discord.gg/disnake!")
56-
elif inter.component.custom_id == "no":
58+
elif inter.component.custom_id == "help_no":
5759
await inter.response.send_message("Got it. Signing off!")
5860
```
5961

60-
## Building and sending buttons
61-
6262
## Button styles
6363

6464
| Name | Syntax | Color |
@@ -89,12 +89,9 @@ async def help_listener(inter: disnake.MessageInteraction):
8989

9090
:::note
9191

92-
`Link` buttons _cannot_ have a `custom_id`, and _do not_ send an interaction event when clicked.
92+
`Link` buttons _cannot_ have a `custom_id`, and _do not_ send an interaction event when clicked.
93+
Nor can their style be customized.
9394

9495
:::
9596

96-
### Disabled buttons
97-
9897
## Receiving button callback
99-
100-
## Views vs. low-level components
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
description: This will be introductionary primer on the aspects of components that are shared between the different styles of components currently offered by Discord
3+
---
4+
5+
# Components Primer
6+
Discord has given us developers the abilltiy to add interactive components to our messages. This section aims to explain some of the nuances of how they work and the differences between the two primary ways of implementing them in Disnake.

guide/sidebars.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ const sidebars = {
2828
link: { type: 'doc', id: 'interactions/intro' },
2929
items: [
3030
'interactions/slash-commands',
31+
'interactions/context-menus',
32+
'interactions/modals',
33+
'interactions/component-primer',
3134
'interactions/buttons',
3235
'interactions/select-menus',
33-
'interactions/modals',
34-
'interactions/context-menus',
3536
],
3637
},
3738
{

0 commit comments

Comments
 (0)