@@ -47,7 +47,6 @@ def _check(i: discord.RawInteractionCreateEvent):
4747
4848########################################################################################################################
4949
50-
5150# Another command where a small embed is sent where you can move the small white ⬜ with the buttons.
5251
5352pointers = []
@@ -61,7 +60,7 @@ def __init__(self, guild: discord.Guild):
6160
6261 @property
6362 def possition_x (self ):
64- return _possition_x
63+ return self . _possition_x
6564
6665 def set_x (self , x : int ):
6766 self ._possition_x += x
@@ -116,7 +115,6 @@ def display(x: int, y: int):
116115empty_button = discord .Button (style = discord .ButtonStyle .Secondary , label = " " , custom_id = "empty" , disabled = True )
117116
118117
119- @property
120118def arrow_button ():
121119 return discord .Button (style = discord .ButtonStyle .Primary )
122120
@@ -126,8 +124,8 @@ async def start_game(ctx: commands.Context):
126124 pointer : Pointer = get_pointer (ctx .guild )
127125 await ctx .send (embed = discord .Embed (title = "Little Game" ,
128126 description = display (x = 0 , y = 0 )),
129- components = [discord .ActionRow (empty_button , arrow_button .set_label ('↑' ).set_custom_id ('up' ), empty_button ),
130- discord .ActionRow (arrow_button .set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ), arrow_button .set_label ('↓' ).set_custom_id ('down' ).disable_if (pointer .possition_y <= 0 ), arrow_button .set_label ('→' ).set_custom_id ('right' ))
127+ components = [discord .ActionRow (empty_button , arrow_button () .set_label ('↑' ).set_custom_id ('up' ), empty_button ),
128+ discord .ActionRow (arrow_button () .set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ), arrow_button () .set_label ('↓' ).set_custom_id ('down' ).disable_if (pointer .possition_y <= 0 ), arrow_button () .set_label ('→' ).set_custom_id ('right' ))
131129 ]
132130 )
133131
@@ -138,37 +136,34 @@ async def on_raw_interaction_create(interaction: discord.RawInteractionCreateEve
138136 pointer : Pointer = get_pointer (interaction .guild )
139137 if not (message := interaction .message ):
140138 message : discord .Message = await interaction .channel .fetch_message (interaction .message_id )
141- if interaction .button .custom_id == "links" :
142- await message .edit (embed = discord .Embed (title = "Du Hast Links gewählt" ), components = [discord .ActionRow (discord .Button (label = 'Links' , custom_id = 'links' , style = discord .ButtonStyle .Secondary , disabled = True ), discord .Button (label = 'Rechts' , custom_id = 'rechts' , style = discord .ButtonStyle .Danger ))])
143- elif interaction .button .custom_id == "rechts" :
144- await message .edit (embed = discord .Embed (title = "Du Hast Rechts gewählt" ), components = [discord .ActionRow (discord .Button (label = 'Links' , custom_id = 'links' , style = discord .ButtonStyle .Danger ), discord .Button (label = 'Rechts' , custom_id = 'rechts' , style = discord .ButtonStyle .Secondary , disabled = True ))])
145- elif interaction .button .custom_id == "up" :
139+ if interaction .button .custom_id == "up" :
146140 pointer .set_y (1 )
147141 await message .edit (embed = discord .Embed (title = "Little Game" ,
148142 description = display (x = pointer .possition_x , y = pointer .possition_y )),
149- components = [discord .ActionRow (empty_button , arrow_button .set_label ('↑' ).set_custom_id ('up' ).disable_if (pointer .possition_y >= 9 ), empty_button ),
150- discord .ActionRow (arrow_button .set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ), arrow_button .set_label ('↓' ).set_custom_id ('down' ), arrow_button .set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
143+ components = [discord .ActionRow (empty_button , arrow_button () .set_label ('↑' ).set_custom_id ('up' ).disable_if (pointer .possition_y >= 9 ), empty_button ),
144+ discord .ActionRow (arrow_button () .set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ), arrow_button () .set_label ('↓' ).set_custom_id ('down' ), arrow_button () .set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
151145 )
152146 elif interaction .button .custom_id == "down" :
153147 pointer .set_y (- 1 )
154148 await message .edit (embed = discord .Embed (title = "Little Game" ,
155149 description = display (x = pointer .possition_x , y = pointer .possition_y )),
156- components = [discord .ActionRow (empty_button , arrow_button .set_label ('↑' ).set_custom_id ('up' ), empty_button ),
157- discord .ActionRow (arrow_button .set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ), arrow_button .set_label ('↓' ).set_custom_id ('down' ).disable_if (pointer .possition_y <= 0 ), arrow_button .set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
150+ components = [discord .ActionRow (empty_button , arrow_button () .set_label ('↑' ).set_custom_id ('up' ), empty_button ),
151+ discord .ActionRow (arrow_button () .set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ), arrow_button () .set_label ('↓' ).set_custom_id ('down' ).disable_if (pointer .possition_y <= 0 ), arrow_button () .set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
158152 )
159153 elif interaction .button .custom_id == "right" :
160154 pointer .set_x (1 )
161155 await message .edit (embed = discord .Embed (title = "Little Game" ,
162156 description = display (x = pointer .possition_x , y = pointer .possition_y )),
163- components = [discord .ActionRow (empty_button , arrow_button .set_label ('↑' ).set_custom_id ('up' ), empty_button ),
164- discord .ActionRow (arrow_button .set_label ('←' ).set_custom_id ('left' ), arrow_button .set_label ('↓' ).set_custom_id ('down' ), arrow_button .set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
157+ components = [discord .ActionRow (empty_button , arrow_button () .set_label ('↑' ).set_custom_id ('up' ), empty_button ),
158+ discord .ActionRow (arrow_button () .set_label ('←' ).set_custom_id ('left' ), arrow_button () .set_label ('↓' ).set_custom_id ('down' ), arrow_button () .set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
165159 )
166160 elif interaction .button .custom_id == "left" :
167161 pointer .set_x (- 1 )
168162 await message .edit (embed = discord .Embed (title = "Little Game" ,
169163 description = display (x = pointer .possition_x , y = pointer .possition_y )),
170- components = [discord .ActionRow (empty_button , arrow_button .set_label ('↑' ).set_custom_id ('up' ), empty_button ),
171- discord .ActionRow (arrow_button .set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ), arrow_button .set_label ('↓' ).set_custom_id ('down' ), arrow_button .set_label ('→' ).set_custom_id ('right' ))]
164+ components = [discord .ActionRow (empty_button , arrow_button () .set_label ('↑' ).set_custom_id ('up' ), empty_button ),
165+ discord .ActionRow (arrow_button () .set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ), arrow_button () .set_label ('↓' ).set_custom_id ('down' ), arrow_button () .set_label ('→' ).set_custom_id ('right' ))]
172166 )
173167
168+
174169client .run ('You Bot-Token here' )
0 commit comments