@@ -62,7 +62,7 @@ def __init__(self, guild: discord.Guild):
6262
6363 @property
6464 def possition_x (self ):
65- return self . _possition_x
65+ return _possition_x
6666
6767 def set_x (self , x : int ):
6868 self ._possition_x += x
@@ -117,6 +117,7 @@ def display(x: int, y: int):
117117empty_button = discord .Button (style = discord .ButtonStyle .Secondary , label = " " , custom_id = "empty" , disabled = True )
118118
119119
120+ @property
120121def arrow_button ():
121122 return discord .Button (style = discord .ButtonStyle .Primary )
122123
@@ -127,45 +128,48 @@ async def start_game(ctx: commands.Context):
127128 await ctx .send (embed = discord .Embed (title = "Little Game" ,
128129 description = display (x = 0 , y = 0 )),
129130 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' ))
131+ discord .ActionRow (arrow_button ().set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ),
132+ arrow_button ().set_label ('↓' ).set_custom_id ('down' ).disable_if (pointer .possition_y <= 0 ),
133+ arrow_button ().set_label ('→' ).set_custom_id ('right' ))
131134 ]
132135 )
133136
134137
135138@client .event
136139async def on_raw_interaction_create (interaction : discord .RawInteractionCreateEvent ):
137- await interaction .defer ()
138- pointer : Pointer = get_pointer (interaction .guild )
139- if not (message := interaction .message ):
140- message : discord .Message = await interaction .channel .fetch_message (interaction .message_id )
141140 if interaction .button .custom_id == "up" :
142141 pointer .set_y (1 )
143- await message .edit (embed = discord .Embed (title = "Little Game" ,
142+ await interaction .edit (embed = discord .Embed (title = "Little Game" ,
144143 description = display (x = pointer .possition_x , y = pointer .possition_y )),
145144 components = [discord .ActionRow (empty_button , arrow_button ().set_label ('↑' ).set_custom_id ('up' ).disable_if (pointer .possition_y >= 9 ), empty_button ),
146- 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 ))]
145+ discord .ActionRow (arrow_button ().set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ),
146+ arrow_button ().set_label ('↓' ).set_custom_id ('down' ),
147+ arrow_button ().set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
147148 )
148149 elif interaction .button .custom_id == "down" :
149150 pointer .set_y (- 1 )
150- await message .edit (embed = discord .Embed (title = "Little Game" ,
151+ await interaction .edit (embed = discord .Embed (title = "Little Game" ,
151152 description = display (x = pointer .possition_x , y = pointer .possition_y )),
152153 components = [discord .ActionRow (empty_button , arrow_button ().set_label ('↑' ).set_custom_id ('up' ), empty_button ),
153- 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 ))]
154+ discord .ActionRow (arrow_button ().set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ),
155+ arrow_button ().set_label ('↓' ).set_custom_id ('down' ).disable_if (pointer .possition_y <= 0 ),
156+ arrow_button ().set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
154157 )
155158 elif interaction .button .custom_id == "right" :
156159 pointer .set_x (1 )
157- await message .edit (embed = discord .Embed (title = "Little Game" ,
160+ await interaction .edit (embed = discord .Embed (title = "Little Game" ,
158161 description = display (x = pointer .possition_x , y = pointer .possition_y )),
159162 components = [discord .ActionRow (empty_button , arrow_button ().set_label ('↑' ).set_custom_id ('up' ), empty_button ),
160- 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 ))]
163+ discord .ActionRow (arrow_button ().set_label ('←' ).set_custom_id ('left' ),
164+ arrow_button ().set_label ('↓' ).set_custom_id ('down' ),
165+ arrow_button ().set_label ('→' ).set_custom_id ('right' ).disable_if (pointer .possition_x >= 9 ))]
161166 )
162167 elif interaction .button .custom_id == "left" :
163168 pointer .set_x (- 1 )
164- await message .edit (embed = discord .Embed (title = "Little Game" ,
169+ await interaction .edit (embed = discord .Embed (title = "Little Game" ,
165170 description = display (x = pointer .possition_x , y = pointer .possition_y )),
166171 components = [discord .ActionRow (empty_button , arrow_button ().set_label ('↑' ).set_custom_id ('up' ), empty_button ),
167- 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' ))]
172+ discord .ActionRow (arrow_button ().set_label ('←' ).set_custom_id ('left' ).disable_if (pointer .possition_x <= 0 ),
173+ arrow_button ().set_label ('↓' ).set_custom_id ('down' ),
174+ arrow_button ().set_label ('→' ).set_custom_id ('right' ))]
168175 )
169-
170-
171- client .run ('You Bot-Token here' )
0 commit comments