Skip to content

Commit 2a14a9a

Browse files
authored
Update examples.py
1 parent 86833ea commit 2a14a9a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

examples.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
client = commands.Bot(command_prefix=commands.when_mentioned_or('.!'), intents=discord.Intents.all(), case_insensitive=True)
77

88

9-
# a command that sends you a message and processes it when you click a button
9+
# A Command that sends you a Message and edit it when you click a Button
1010

1111

1212
@client.command(name='buttons', description='sends you some nice Buttons')
1313
async def buttons(ctx: commands.Context):
1414
components = [ActionRow(Button(label='Option Nr.1',
1515
custom_id='option1',
16-
emoji='1️⃣',
16+
emoji="🆒",
1717
style=ButtonColor.green
1818
),
1919
Button(label='Option Nr.2',
2020
custom_id='option2',
21-
emoji='2️⃣',
21+
emoji="🆗",
2222
style=ButtonColor.blurple)),
2323
ActionRow(Button(label='A Other Row',
2424
custom_id='sec_row_1st option',
@@ -37,14 +37,16 @@ def _check(i: discord.RawInteractionCreateEvent):
3737
interaction: discord.RawInteractionCreateEvent = await client.wait_for('interaction_create', check=_check)
3838
button_id = interaction.button.custom_id
3939

40-
# 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).
40+
# This sends the Discord-API that the interaction has been received and is being "processed"
41+
#(if this is not used, and you don't edit the message like below Discord will indicate that the interaction failed).
4142
await interaction.defer()
42-
await interaction.message.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'),
43+
44+
await interaction.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'),
4345
components=[components[0].disable_all_buttons(), components[1].disable_all_buttons()])
4446

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

47-
49+
client.run('You Bot-Token here')
4850
########################################################################################################################
4951

5052
# Another command where a small embed is sent where you can move the small white ⬜ with the buttons.

0 commit comments

Comments
 (0)