@@ -87,11 +87,11 @@ A Command that sends you a Message and edit it when you click a Button:
8787 an_embed = discord.Embed(title = ' Here are some Button\' s' , description = ' Choose an option' , color = discord.Color.random())
8888 msg = await ctx.send(embed = an_embed, components = components)
8989
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
9292
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
9595
9696 # This sends the Discord-API that the interaction has been received and is being "processed"
9797 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
195195
196196
197197 @client.event
198- async def on_raw_interaction_create (interaction : discord.RawInteractionCreateEvent ):
198+ async def on_raw_button_click (interaction : discord.Interaction ):
199199 await interaction.defer()
200200 pointer: Pointer = get_pointer(interaction.guild)
201201 if not (message := interaction.message):
202202 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" :
204204 pointer.set_y(1 )
205205 await message.edit(embed = discord.Embed(title = " Little Game" ,
206206 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
209209 arrow_button().set_label(' ↓' ).set_custom_id(' down' ),
210210 arrow_button().set_label(' →' ).set_custom_id(' right' ).disable_if(pointer.possition_x >= 9 ))]
211211 )
212- elif interaction.button .custom_id == " down" :
212+ elif interaction.component .custom_id == " down" :
213213 pointer.set_y(- 1 )
214214 await message.edit(embed = discord.Embed(title = " Little Game" ,
215215 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
218218 arrow_button().set_label(' ↓' ).set_custom_id(' down' ).disable_if(pointer.possition_y <= 0 ),
219219 arrow_button().set_label(' →' ).set_custom_id(' right' ).disable_if(pointer.possition_x >= 9 ))]
220220 )
221- elif interaction.button .custom_id == " right" :
221+ elif interaction.component .custom_id == " right" :
222222 pointer.set_x(1 )
223223 await message.edit(embed = discord.Embed(title = " Little Game" ,
224224 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
227227 arrow_button().set_label(' ↓' ).set_custom_id(' down' ),
228228 arrow_button().set_label(' →' ).set_custom_id(' right' ).disable_if(pointer.possition_x >= 9 ))]
229229 )
230- elif interaction.button .custom_id == " left" :
230+ elif interaction.component .custom_id == " left" :
231231 pointer.set_x(- 1 )
232232 await message.edit(embed = discord.Embed(title = " Little Game" ,
233233 description = display(x = pointer.possition_x, y = pointer.possition_y)),
234234 components = [discord.ActionRow(empty_button, arrow_button().set_label(' ↑' ).set_custom_id(' up' ), empty_button),
235235 discord.ActionRow(arrow_button().set_label(' ←' ).set_custom_id(' left' ).disable_if(pointer.possition_x <= 0 ),
236236 arrow_button().set_label(' ↓' ).set_custom_id(' down' ),
237237 arrow_button().set_label(' →' ).set_custom_id(' right' ))]
238- )
238+ )
0 commit comments