Skip to content

Commit 43db2a9

Browse files
authored
Update examples.py
1 parent af07707 commit 43db2a9

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

examples.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import typing
12
import discord
23
from discord.ext import commands
34
from discord import ActionRow, Button, ButtonColor
@@ -12,7 +13,7 @@
1213
async def buttons(ctx: commands.Context):
1314
components = [ActionRow(Button(label='Option Nr.1',
1415
custom_id='option1',
15-
emoji='1️1️⃣2️',
16+
emoji='1️⃣',
1617
style=ButtonColor.green
1718
),
1819
Button(label='Option Nr.2',
@@ -21,6 +22,7 @@ async def buttons(ctx: commands.Context):
2122
style=ButtonColor.blurple)),
2223
ActionRow(Button(label='A Other Row',
2324
custom_id='sec_row_1st option',
25+
style=ButtonColor.red,
2426
emoji='😀'),
2527
Button(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
2628
label="This is an Link",
@@ -37,16 +39,8 @@ def _check(i: discord.RawInteractionCreateEvent):
3739

3840
# 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).
3941
await interaction.defer()
40-
41-
if button_id == "option1":
42-
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]])
43-
44-
elif button_id == "option2":
45-
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]])
46-
47-
elif button_id == 'sec_row_1st option':
48-
await interaction.message.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'),
49-
components=[components[0], components[1].edit_obj(0, disabled=True)])
42+
await interaction.message.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'),
43+
components=[components[0].disable_all_buttons(), components[1].disable_all_buttons()])
5044

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

0 commit comments

Comments
 (0)