@@ -87,11 +87,11 @@ A Command that sends you a Message and edit it when you click a Button:
87
87
an_embed = discord.Embed(title = ' Here are some Button\' s' , description = ' Choose an option' , color = discord.Color.random())
88
88
msg = await ctx.send(embed = an_embed, components = components)
89
89
90
- def _check (i : discord.RawInteractionCreateEvent ):
91
- return i.message == msg and i.member == ctx.author
90
+ def _check (i : discord.Interaction, b : discord.ButtonClik ):
91
+ return i.message == msg and i.author == ctx.author
92
92
93
- interaction: discord.RawInteractionCreateEvent = await client.wait_for(' interaction_create ' , check = _check)
94
- button_id = interaction. button.custom_id
93
+ interaction, button = await client.wait_for(' button_click ' , check = _check)
94
+ button_id = button.custom_id
95
95
96
96
# This sends the Discord-API that the interaction has been received and is being "processed"
97
97
await interaction.defer() # if this is not used and you also do not edit the message within 3 seconds as described below, Discord will indicate that the interaction has failed.
@@ -195,12 +195,12 @@ Another (complex) Example where a small Embed will be send; you can move a small
195
195
196
196
197
197
@client.event
198
- async def on_raw_interaction_create (interaction : discord.RawInteractionCreateEvent ):
198
+ async def on_raw_button_click (interaction : discord.Interaction ):
199
199
await interaction.defer()
200
200
pointer: Pointer = get_pointer(interaction.guild)
201
201
if not (message := interaction.message):
202
202
message: discord.Message = await interaction.channel.fetch_message(interaction.message_id)
203
- if interaction.button .custom_id == " up" :
203
+ if interaction.component .custom_id == " up" :
204
204
pointer.set_y(1 )
205
205
await message.edit(embed = discord.Embed(title = " Little Game" ,
206
206
description = display(x = pointer.possition_x, y = pointer.possition_y)),
@@ -209,7 +209,7 @@ Another (complex) Example where a small Embed will be send; you can move a small
209
209
arrow_button().set_label(' ↓' ).set_custom_id(' down' ),
210
210
arrow_button().set_label(' →' ).set_custom_id(' right' ).disable_if(pointer.possition_x >= 9 ))]
211
211
)
212
- elif interaction.button .custom_id == " down" :
212
+ elif interaction.component .custom_id == " down" :
213
213
pointer.set_y(- 1 )
214
214
await message.edit(embed = discord.Embed(title = " Little Game" ,
215
215
description = display(x = pointer.possition_x, y = pointer.possition_y)),
@@ -218,7 +218,7 @@ Another (complex) Example where a small Embed will be send; you can move a small
218
218
arrow_button().set_label(' ↓' ).set_custom_id(' down' ).disable_if(pointer.possition_y <= 0 ),
219
219
arrow_button().set_label(' →' ).set_custom_id(' right' ).disable_if(pointer.possition_x >= 9 ))]
220
220
)
221
- elif interaction.button .custom_id == " right" :
221
+ elif interaction.component .custom_id == " right" :
222
222
pointer.set_x(1 )
223
223
await message.edit(embed = discord.Embed(title = " Little Game" ,
224
224
description = display(x = pointer.possition_x, y = pointer.possition_y)),
@@ -227,12 +227,12 @@ Another (complex) Example where a small Embed will be send; you can move a small
227
227
arrow_button().set_label(' ↓' ).set_custom_id(' down' ),
228
228
arrow_button().set_label(' →' ).set_custom_id(' right' ).disable_if(pointer.possition_x >= 9 ))]
229
229
)
230
- elif interaction.button .custom_id == " left" :
230
+ elif interaction.component .custom_id == " left" :
231
231
pointer.set_x(- 1 )
232
232
await message.edit(embed = discord.Embed(title = " Little Game" ,
233
233
description = display(x = pointer.possition_x, y = pointer.possition_y)),
234
234
components = [discord.ActionRow(empty_button, arrow_button().set_label(' ↑' ).set_custom_id(' up' ), empty_button),
235
235
discord.ActionRow(arrow_button().set_label(' ←' ).set_custom_id(' left' ).disable_if(pointer.possition_x <= 0 ),
236
236
arrow_button().set_label(' ↓' ).set_custom_id(' down' ),
237
237
arrow_button().set_label(' →' ).set_custom_id(' right' ))]
238
- )
238
+ )
0 commit comments