@@ -64,16 +64,15 @@ async def buttons(ctx: commands.Context):
64
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
65
66
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} ` ' ),
68
- components = [components[0 ], components[1 ].edit_obj(0 , disabled = True )])
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 )])
69
68
70
69
# The Discord API doesn't send an event when you press a link button so we can't "receive" that.
71
-
72
- client.run(' Your Bot-Token here' )
70
+
71
+ client.run(' You Bot-Token here' )
73
72
```
74
- ----------------------------------------------------------------------------------------------------
75
- ``` py
73
+ ---------------------------------------------------------------
76
74
75
+ ``` py
77
76
# Another command where a small embed is sent where you can move the small white ⬜ with the buttons.
78
77
79
78
pointers = []
@@ -107,6 +106,7 @@ def get_pointer(obj: typing.Union[discord.Guild, int]):
107
106
for p in pointers:
108
107
if p.guild.id == obj.id:
109
108
return p
109
+ pointers.append(Pointer(obj))
110
110
return get_pointer(obj)
111
111
112
112
elif isinstance (obj, int ):
@@ -146,6 +146,18 @@ def arrow_button():
146
146
return discord.Button(style = discord.ButtonStyle.Primary)
147
147
148
148
149
+ @client.command (name = " start_game" )
150
+ async def start_game (ctx : commands.Context):
151
+ pointer: Pointer = get_pointer(ctx.guild)
152
+ await ctx.send(embed = discord.Embed(title = " Little Game" ,
153
+ description = self .display(x = 0 , y = 0 )),
154
+ components = [discord.ActionRow(self .empty_button, self .arrow_button.set_label(' ↑' ).set_custom_id(' up' ), self .empty_button),
155
+ discord.ActionRow(self .arrow_button.set_label(' ←' ).set_custom_id(' left' ).disable_if(pointer.possition_x <= 0 ), self .arrow_button.set_label(' ↓' ).set_custom_id(' down' ).disable_if(pointer.possition_y <= 0 ), self .arrow_button.set_label(' →' ).set_custom_id(' right' ))
156
+ ]
157
+ )
158
+
159
+
160
+ @client.event
149
161
async def on_raw_interaction_create (interaction : discord.RawInteractionCreateEvent):
150
162
await interaction.defer()
151
163
pointer: Pointer = get_pointer(interaction.guild)
0 commit comments