@@ -47,7 +47,6 @@ def _check(i: discord.RawInteractionCreateEvent):
47
47
48
48
########################################################################################################################
49
49
50
-
51
50
# Another command where a small embed is sent where you can move the small white ⬜ with the buttons.
52
51
53
52
pointers = []
@@ -61,7 +60,7 @@ def __init__(self, guild: discord.Guild):
61
60
62
61
@property
63
62
def possition_x (self ):
64
- return _possition_x
63
+ return self . _possition_x
65
64
66
65
def set_x (self , x : int ):
67
66
self ._possition_x += x
@@ -116,7 +115,6 @@ def display(x: int, y: int):
116
115
empty_button = discord .Button (style = discord .ButtonStyle .Secondary , label = " " , custom_id = "empty" , disabled = True )
117
116
118
117
119
- @property
120
118
def arrow_button ():
121
119
return discord .Button (style = discord .ButtonStyle .Primary )
122
120
@@ -126,8 +124,8 @@ async def start_game(ctx: commands.Context):
126
124
pointer : Pointer = get_pointer (ctx .guild )
127
125
await ctx .send (embed = discord .Embed (title = "Little Game" ,
128
126
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' ))
131
129
]
132
130
)
133
131
@@ -138,37 +136,34 @@ async def on_raw_interaction_create(interaction: discord.RawInteractionCreateEve
138
136
pointer : Pointer = get_pointer (interaction .guild )
139
137
if not (message := interaction .message ):
140
138
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" :
146
140
pointer .set_y (1 )
147
141
await message .edit (embed = discord .Embed (title = "Little Game" ,
148
142
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 ))]
151
145
)
152
146
elif interaction .button .custom_id == "down" :
153
147
pointer .set_y (- 1 )
154
148
await message .edit (embed = discord .Embed (title = "Little Game" ,
155
149
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 ))]
158
152
)
159
153
elif interaction .button .custom_id == "right" :
160
154
pointer .set_x (1 )
161
155
await message .edit (embed = discord .Embed (title = "Little Game" ,
162
156
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 ))]
165
159
)
166
160
elif interaction .button .custom_id == "left" :
167
161
pointer .set_x (- 1 )
168
162
await message .edit (embed = discord .Embed (title = "Little Game" ,
169
163
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' ))]
172
166
)
173
167
168
+
174
169
client .run ('You Bot-Token here' )
0 commit comments