@@ -4,13 +4,30 @@ The Original [discord.py](https://github.com/Rapptz/discord.py) Libary made by [
4
4
([ discord] ( https://discord.com/channels/@me ) -User ` mccuber04#2960 ` )
5
5
6
6
## Installation:
7
+ ### With pip:
8
+ #### first uninstall the normal discord.py Libary:
9
+ ``` ps
10
+ # Linux/macOS
11
+ python3 -m pip uninstall discord.py
12
+
13
+ # Windows
14
+ py -3 -m pip uninstall discord.py
15
+ ```
16
+ #### then install this libary using:
17
+ ``` ps
18
+ # Linux/macOS
19
+ python3 -m pip install -U discord.py-message-components
7
20
8
- Replace the [ discord] ( file:///\C:/%APPDATA%/Local/Programs/Python/Python39/Lib/site-packages/discord ) folder in the site-packages with the discord folder contained in this repository or yust clone it with git.
9
-
21
+ # Windows
22
+ py -3 -m pip install -U discord.py-message-components
23
+ ```
24
+ ### Manual:
25
+ ```
26
+ Replace the discord folder in the site-packages with the discord folder contained in this repository or yust clone it with git.
27
+ ```
10
28
11
29
## Questions or ideas?
12
-
13
- Send me a direct-message on [ Discord] ( https://discord.com/channels/@me ) : ` mccuber04#2960 `
30
+ Open an Pull request on [ GitHub] ( https://github.com/mccoderpy/discord.py-with-message-components/pulls ) or Send me a direct-message on [ Discord] ( https://discord.com/channels/@me ) : ` mccuber04#2960 `
14
31
15
32
--------------------------------------------------------
16
33
@@ -81,7 +98,7 @@ class Pointer:
81
98
82
99
@ property
83
100
def possition_x (self ):
84
- return self . _possition_x
101
+ return _possition_x
85
102
86
103
def set_x (self , x : int ):
87
104
self ._possition_x += x
@@ -136,6 +153,7 @@ def display(x: int, y: int):
136
153
empty_button = discord.Button(style = discord.ButtonStyle.Secondary, label = " " , custom_id = " empty" , disabled = True )
137
154
138
155
156
+ @ property
139
157
def arrow_button ():
140
158
return discord.Button(style = discord.ButtonStyle.Primary)
141
159
@@ -145,8 +163,8 @@ async def start_game(ctx: commands.Context):
145
163
pointer: Pointer = get_pointer(ctx.guild)
146
164
await ctx.send(embed = discord.Embed(title = " Little Game" ,
147
165
description = display(x = 0 , y = 0 )),
148
- components = [discord.ActionRow(empty_button, arrow_button() .set_label(' ↑' ).set_custom_id(' up' ), empty_button),
149
- 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' ))
166
+ 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' ).disable_if(pointer.possition_y <= 0 ), arrow_button.set_label(' →' ).set_custom_id(' right' ))
150
168
]
151
169
)
152
170
@@ -157,33 +175,37 @@ async def on_raw_interaction_create(interaction: discord.RawInteractionCreateEve
157
175
pointer: Pointer = get_pointer(interaction.guild)
158
176
if not (message := interaction.message):
159
177
message: discord.Message = await interaction.channel.fetch_message(interaction.message_id)
160
- if interaction.button.custom_id == " up" :
178
+ if interaction.button.custom_id == " links" :
179
+ 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))])
180
+ elif interaction.button.custom_id == " rechts" :
181
+ 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 ))])
182
+ elif interaction.button.custom_id == " up" :
161
183
pointer.set_y(1 )
162
184
await message.edit(embed = discord.Embed(title = " Little Game" ,
163
185
description = display(x = pointer.possition_x, y = pointer.possition_y)),
164
- components = [discord.ActionRow(empty_button, arrow_button() .set_label(' ↑' ).set_custom_id(' up' ).disable_if(pointer.possition_y >= 9 ), 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' ).disable_if(pointer.possition_x >= 9 ))]
186
+ components = [discord.ActionRow(empty_button, arrow_button.set_label(' ↑' ).set_custom_id(' up' ).disable_if(pointer.possition_y >= 9 ), empty_button),
187
+ 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 ))]
166
188
)
167
189
elif interaction.button.custom_id == " down" :
168
190
pointer.set_y(- 1 )
169
191
await message.edit(embed = discord.Embed(title = " Little Game" ,
170
192
description = display(x = pointer.possition_x, y = pointer.possition_y)),
171
- components = [discord.ActionRow(empty_button, arrow_button() .set_label(' ↑' ).set_custom_id(' up' ), empty_button),
172
- 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 ))]
193
+ components = [discord.ActionRow(empty_button, arrow_button.set_label(' ↑' ).set_custom_id(' up' ), empty_button),
194
+ 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 ))]
173
195
)
174
196
elif interaction.button.custom_id == " right" :
175
197
pointer.set_x(1 )
176
198
await message.edit(embed = discord.Embed(title = " Little Game" ,
177
199
description = display(x = pointer.possition_x, y = pointer.possition_y)),
178
- components = [discord.ActionRow(empty_button, arrow_button() .set_label(' ↑' ).set_custom_id(' up' ), empty_button),
179
- 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 ))]
200
+ components = [discord.ActionRow(empty_button, arrow_button.set_label(' ↑' ).set_custom_id(' up' ), empty_button),
201
+ 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 ))]
180
202
)
181
203
elif interaction.button.custom_id == " left" :
182
204
pointer.set_x(- 1 )
183
205
await message.edit(embed = discord.Embed(title = " Little Game" ,
184
206
description = display(x = pointer.possition_x, y = pointer.possition_y)),
185
- components = [discord.ActionRow(empty_button, arrow_button() .set_label(' ↑' ).set_custom_id(' up' ), empty_button),
186
- 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' ))]
207
+ components = [discord.ActionRow(empty_button, arrow_button.set_label(' ↑' ).set_custom_id(' up' ), empty_button),
208
+ 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' ))]
187
209
)
188
210
189
211
```
0 commit comments