Skip to content

Commit 19b1863

Browse files
authored
Update README.md
1 parent be257f1 commit 19b1863

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Send me a direct-message on [Discord](https://discord.com/channels/@me): `mccube
1717
# Examples:
1818

1919
```py
20+
import typing
2021
import discord
2122
from discord.ext import commands
2223
from discord import ActionRow, Button, ButtonColor
@@ -31,7 +32,7 @@ client = commands.Bot(command_prefix=commands.when_mentioned_or('.!'), intents=d
3132
async def buttons(ctx: commands.Context):
3233
components = [ActionRow(Button(label='Option Nr.1',
3334
custom_id='option1',
34-
emoji='1️1️⃣2️',
35+
emoji='1️⃣',
3536
style=ButtonColor.green
3637
),
3738
Button(label='Option Nr.2',
@@ -40,6 +41,7 @@ async def buttons(ctx: commands.Context):
4041
style=ButtonColor.blurple)),
4142
ActionRow(Button(label='A Other Row',
4243
custom_id='sec_row_1st option',
44+
style=ButtonColor.red,
4345
emoji='😀'),
4446
Button(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
4547
label="This is an Link",
@@ -56,15 +58,8 @@ async def buttons(ctx: commands.Context):
5658

5759
# This sends the Discord-API that the interaction has been received and is being "processed" (if this is not used, Discord will indicate that the interaction failed).
5860
await interaction.defer()
59-
60-
if button_id == "option1":
61-
await interaction.message.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'), components=[components[0].edit_obj(0, disabled=True), components[1]])
62-
63-
elif button_id == "option2":
64-
await interaction.message.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'), components=[components[0].edit_obj(1, disabled=True), components[1]])
65-
66-
elif button_id == 'sec_row_1st option':
67-
await interaction.message.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'), components=[components[0], components[1].edit_obj(0, disabled=True)])
61+
await interaction.message.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'),
62+
components=[components[0].disable_all_buttons(), components[1].disable_all_buttons()])
6863

6964
# The Discord API doesn't send an event when you press a link button so we can't "receive" that.
7065

@@ -73,8 +68,6 @@ client.run('You Bot-Token here')
7368
---------------------------------------------------------------
7469

7570
```py
76-
# Another command where a small embed is sent where you can move the small white ⬜ with the buttons.
77-
7871
pointers = []
7972

8073

0 commit comments

Comments
 (0)