@@ -62,7 +62,7 @@ def __init__(self, guild: discord.Guild):
62
62
63
63
@property
64
64
def possition_x (self ):
65
- return self . _possition_x
65
+ return _possition_x
66
66
67
67
def set_x (self , x : int ):
68
68
self ._possition_x += x
@@ -117,6 +117,7 @@ def display(x: int, y: int):
117
117
empty_button = discord .Button (style = discord .ButtonStyle .Secondary , label = " " , custom_id = "empty" , disabled = True )
118
118
119
119
120
+ @property
120
121
def arrow_button ():
121
122
return discord .Button (style = discord .ButtonStyle .Primary )
122
123
@@ -127,45 +128,48 @@ async def start_game(ctx: commands.Context):
127
128
await ctx .send (embed = discord .Embed (title = "Little Game" ,
128
129
description = display (x = 0 , y = 0 )),
129
130
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' ))
131
134
]
132
135
)
133
136
134
137
135
138
@client .event
136
139
async 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 )
141
140
if interaction .button .custom_id == "up" :
142
141
pointer .set_y (1 )
143
- await message .edit (embed = discord .Embed (title = "Little Game" ,
142
+ await interaction .edit (embed = discord .Embed (title = "Little Game" ,
144
143
description = display (x = pointer .possition_x , y = pointer .possition_y )),
145
144
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 ))]
147
148
)
148
149
elif interaction .button .custom_id == "down" :
149
150
pointer .set_y (- 1 )
150
- await message .edit (embed = discord .Embed (title = "Little Game" ,
151
+ await interaction .edit (embed = discord .Embed (title = "Little Game" ,
151
152
description = display (x = pointer .possition_x , y = pointer .possition_y )),
152
153
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 ))]
154
157
)
155
158
elif interaction .button .custom_id == "right" :
156
159
pointer .set_x (1 )
157
- await message .edit (embed = discord .Embed (title = "Little Game" ,
160
+ await interaction .edit (embed = discord .Embed (title = "Little Game" ,
158
161
description = display (x = pointer .possition_x , y = pointer .possition_y )),
159
162
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 ))]
161
166
)
162
167
elif interaction .button .custom_id == "left" :
163
168
pointer .set_x (- 1 )
164
- await message .edit (embed = discord .Embed (title = "Little Game" ,
169
+ await interaction .edit (embed = discord .Embed (title = "Little Game" ,
165
170
description = display (x = pointer .possition_x , y = pointer .possition_y )),
166
171
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' ))]
168
175
)
169
-
170
-
171
- client .run ('You Bot-Token here' )
0 commit comments