Skip to content

Commit 9f4d93c

Browse files
authored
Updated Main-Branch(docs) to 1.7.5.1
1 parent 2a114eb commit 9f4d93c

26 files changed

+1067
-298
lines changed

LICENSE

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
The MIT License (MIT)
2-
3-
Copyright (c) 2015-present Rapptz
4-
5-
Implementing of the Discord-Message-components made by mccoderpy (Discord-User mccuber04#2960)
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a
8-
copy of this software and associated documentation files (the "Software"),
9-
to deal in the Software without restriction, including without limitation
10-
the rights to use, copy, modify, merge, publish, distribute, sublicense,
11-
and/or sell copies of the Software, and to permit persons to whom the
12-
Software is furnished to do so, subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in
15-
all copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18-
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23-
DEALINGS IN THE SOFTWARE.
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015-present Rapptz
4+
5+
Implementing of the Discord-Message-components made by mccoderpy (Discord-User mccuber04#2960)
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a
8+
copy of this software and associated documentation files (the "Software"),
9+
to deal in the Software without restriction, including without limitation
10+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
11+
and/or sell copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in
15+
all copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.

MANIFEST.in

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include README.rst
2+
include LICENSE.txt
3+
include discord/*
4+
include discord/bin/*.dll
5+
include discord/ext/commands/*
6+
include discord/ext/tasks/__init__.py

README.rst

+80-57
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,55 @@
1-
.. image:: https://cdn.discordapp.com/attachments/852872100073963532/854711446767796286/discord.py-message-components.png
2-
:target: https://pypi.org/project/discord.py-message-components
3-
:alt: Name of the project
4-
5-
.. image:: https://discord.com/api/guilds/852871920411475968/embed.png
6-
:target: https://discord.gg/sb69muSqsg
7-
:alt: Discord Server Invite
1+
Welcome to discord.py-message-components' documentation!
2+
=========================================================
83

9-
.. image:: https://img.shields.io/pypi/v/discord.py-message-components.svg
10-
:target: https://pypi.python.org/pypi/discord.py-message-components
11-
:alt: PyPI version info
4+
.. figure:: https://cdn.discordapp.com/attachments/852872100073963532/854711446767796286/discord.py-message-components.png
5+
:name: discord.py-message-components
6+
:align: center
7+
:alt: Name of the Project (discord.py-message-components)
128

13-
.. image:: https://img.shields.io/pypi/pyversions/discord.py-message-components.svg
14-
:target: https://pypi.python.org/pypi/discord.py-message-components
15-
:alt: PyPI supported Python versions
16-
17-
.. image:: https://static.pepy.tech/personalized-badge/discord-py-message-components?period=total&units=international_system&left_color=grey&right_color=green&left_text=Downloads
18-
:target: https://pepy.tech/project/discord.py-message-components
19-
:alt: Total downloads for the project
9+
..
10+
.. image:: https://discord.com/api/guilds/852871920411475968/embed.png
11+
:target: https://discord.gg/sb69muSqsg
12+
:alt: Discord Server Invite
2013

21-
.. image:: https://readthedocs.org/projects/discordpy-message-components/badge/?version=latest
22-
:target: https://discordpy-message-components.readthedocs.io/en/latest/
23-
:alt: Documentation Status
14+
.. image:: https://img.shields.io/pypi/v/discord.py-message-components.svg
15+
:target: https://pypi.python.org/pypi/discord.py-message-components
16+
:alt: PyPI version info
2417

25-
The Original `discord.py <https://pypi.org/project/discord.py>`_ Library made by `Rapptz <https://github.com/Rapptz>`_ with implementation of the `Discord-Message-Components <https://discord.com/developers/docs/interactions/message-components>`_ by `mccoderpy <https://github.com/mccoderpy/>`_
18+
.. image:: https://img.shields.io/pypi/pyversions/discord.py-message-components.svg
19+
:target: https://pypi.python.org/pypi/discord.py-message-components
20+
:alt: PyPI supported Python versions
2621

27-
**Documentation:** `read the docs <https://discordpy-message-components.readthedocs.io/en/latest/>`_
22+
.. image:: https://static.pepy.tech/personalized-badge/discord-py-message-components?period=total&units=international_system&left_color=grey&right_color=green&left_text=Downloads
23+
:target: https://pepy.tech/project/discord.py-message-components
24+
:alt: Total downloads for the project
2825

29-
Questions, Bugs or Ideas
30-
________________________
26+
.. image:: https://readthedocs.org/projects/discordpy-message-components/badge/?version=latest
27+
:target: https://discordpy-message-components.readthedocs.io/en/latest/
28+
:alt: Documentation Status
3129

32-
Open a Issue/Pull request on `GitHub <https://github.com/mccoderpy/discord.py-message-components/pulls>`_, join the `support-Server <https://discord.gg/sb69muSqsg>`_ or send me a direct-message on `Discord <https://discord.com/channels/@me>`_: ``mccuber04#2960``
30+
The Original `discord.py <https://pypi.org/project/discord.py/1.7.3>`_ Library made by `Rapptz <https://github.com/Rapptz>`_ with implementation of the `Discord-Message-Components <https://discord.com/developers/docs/interactions/message-components>`_ by `mccoderpy <https://github.com/mccoderpy/>`_
31+
32+
.. figure:: images/rtd-logo-wordmark-light.png
33+
:name: discord.py-message-components documentation
34+
:alt: Link to the documentation of discord.py-message-components
35+
:align: center
36+
:scale: 20%
37+
:target: https://discordpy-message-components.readthedocs.io/en/latest/
38+
39+
**Read the Documentation** `here <https://discordpy-message-components.readthedocs.io/en/latest/>`_
40+
41+
You need help? Or have ideas/feedback?
42+
______________________________________
3343

44+
Open a Issue/Pull request on `GitHub <https://github.com/mccoderpy/discord.py-message-components/pulls>`_, join the `support-Server <https://discord.gg/sb69muSqsg>`_ or send me a direct-message on `Discord <https://discord.com/channels/@me>`_: ``mccuber04#2960``
3445

3546
Installing
3647
__________
3748

3849
**Python 3.5.3 or higher is required**
3950

40-
first uninstall the original `discord.py <https://pypi.org/project/discord.py>`_ Library:
51+
This Library overwrite the original discord.py Library so to be sure all will work fine
52+
first uninstall the original `discord.py <https://pypi.org/project/discord.py/1.7.3>`_ Library if it is installed:
4153

4254
.. code:: sh
4355
@@ -47,7 +59,7 @@ first uninstall the original `discord.py <https://pypi.org/project/discord.py>`_
4759
# Windows
4860
py -3 -m pip uninstall discord.py
4961
50-
then install `this Library <https://pypi.org/project/discord.py-message-components>`_ using:
62+
Then install `this Library <https://pypi.org/project/discord.py-message-components>`_ using:
5163

5264
.. code:: sh
5365
@@ -68,7 +80,7 @@ A Command that sends you a Message and edit it when you click a Button:
6880
import typing
6981
import discord
7082
from discord.ext import commands
71-
from discord import ActionRow, Button, ButtonColor
83+
from discord import ActionRow, Button, ButtonStyle
7284
7385
client = commands.Bot(command_prefix=commands.when_mentioned_or('.!'), intents=discord.Intents.all(), case_insensitive=True)
7486
@@ -77,33 +89,37 @@ A Command that sends you a Message and edit it when you click a Button:
7789
components = [ActionRow(Button(label='Option Nr.1',
7890
custom_id='option1',
7991
emoji="🆒",
80-
style=ButtonColor.green
92+
style=ButtonStyle.green
8193
),
8294
Button(label='Option Nr.2',
8395
custom_id='option2',
8496
emoji="🆗",
85-
style=ButtonColor.blurple)),
97+
style=ButtonStyle.blurple)),
8698
ActionRow(Button(label='A Other Row',
8799
custom_id='sec_row_1st option',
88-
style=ButtonColor.red,
100+
style=ButtonStyle.red,
89101
emoji='😀'),
90102
Button(url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
91103
label="This is an Link",
104+
style=ButtonStyle.url,
92105
emoji='🎬'))
93106
]
94107
an_embed = discord.Embed(title='Here are some Button\'s', description='Choose an option', color=discord.Color.random())
95108
msg = await ctx.send(embed=an_embed, components=components)
96109
97-
def _check(i: discord.Interaction, b: discord.ButtonClick):
110+
def _check(i: discord.Interaction, b):
98111
return i.message == msg and i.member == ctx.author
99112
100113
interaction, button = await client.wait_for('button_click', check=_check)
101114
button_id = button.custom_id
102115
103116
# This sends the Discord-API that the interaction has been received and is being "processed"
104-
await interaction.defer() # if this is not used and you also do not edit the message within 3 seconds as described below, Discord will indicate that the interaction has failed.
117+
await interaction.defer()
118+
# if this is not used and you also do not edit the message within 3 seconds as described below,
119+
# Discord will indicate that the interaction has failed.
105120
106-
# If you use interaction.edit instead of interaction.message.edit, you do not have to deffer the interaction if your response does not last longer than 3 seconds.
121+
# If you use interaction.edit instead of interaction.message.edit, you do not have to defer the interaction,
122+
# if your response does not last longer than 3 seconds.
107123
await interaction.edit(embed=an_embed.add_field(name='Choose', value=f'Your Choose was `{button_id}`'),
108124
components=[components[0].disable_all_buttons(), components[1].disable_all_buttons()])
109125
@@ -176,7 +192,7 @@ Another (complex) Example where a small Embed will be send; you can move a small
176192
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
177193
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
178194
]
179-
base[y].__setitem__(x, 1)
195+
base[y][x] = 1
180196
base.reverse()
181197
return ''.join(f"\n{''.join([str(base[i][w]) for w in range(len(base[i]))]).replace('0', '').replace('1', '')}" for i in range(len(base)))
182198
@@ -201,45 +217,52 @@ Another (complex) Example where a small Embed will be send; you can move a small
201217
)
202218
203219
204-
@client.event
205-
async def on_raw_interaction_create(interaction: discord.Interaction):
206-
await interaction.defer()
220+
@client.on_click()
221+
async def up(i: discord.Interaction, button):
207222
pointer: Pointer = get_pointer(interaction.guild)
208-
if not (message := interaction.message):
209-
message: discord.Message = await interaction.channel.fetch_message(interaction.message_id)
210-
if interaction.component.custom_id == "up":
211-
pointer.set_y(1)
212-
await message.edit(embed=discord.Embed(title="Little Game",
213-
description=display(x=pointer.possition_x, y=pointer.possition_y)),
223+
pointer.set_y(1)
224+
await i.edit(embed=discord.Embed(title="Little Game",
225+
description=display(x=pointer.possition_x, y=pointer.possition_y)),
214226
components=[discord.ActionRow(empty_button, arrow_button().set_label('').set_custom_id('up').disable_if(pointer.possition_y >= 9), empty_button),
215227
discord.ActionRow(arrow_button().set_label('').set_custom_id('left').disable_if(pointer.possition_x <= 0),
216228
arrow_button().set_label('').set_custom_id('down'),
217229
arrow_button().set_label('').set_custom_id('right').disable_if(pointer.possition_x >= 9))]
218230
)
219-
elif interaction.component.custom_id == "down":
220-
pointer.set_y(-1)
221-
await message.edit(embed=discord.Embed(title="Little Game",
222-
description=display(x=pointer.possition_x, y=pointer.possition_y)),
231+
232+
@client.on_click()
233+
async def down(i: discord.Interaction, button):
234+
pointer: Pointer = get_pointer(interaction.guild)
235+
pointer.set_y(-1)
236+
await message.edit(embed=discord.Embed(title="Little Game",
237+
description=display(x=pointer.possition_x, y=pointer.possition_y)),
223238
components=[discord.ActionRow(empty_button, arrow_button().set_label('').set_custom_id('up'), empty_button),
224239
discord.ActionRow(arrow_button().set_label('').set_custom_id('left').disable_if(pointer.possition_x <= 0),
225240
arrow_button().set_label('').set_custom_id('down').disable_if(pointer.possition_y <= 0),
226241
arrow_button().set_label('').set_custom_id('right').disable_if(pointer.possition_x >= 9))]
227242
)
228-
elif interaction.component.custom_id == "right":
229-
pointer.set_x(1)
230-
await message.edit(embed=discord.Embed(title="Little Game",
231-
description=display(x=pointer.possition_x, y=pointer.possition_y)),
243+
244+
@client.on_click()
245+
async def right(i: discord.Interaction, button):
246+
pointer: Pointer = get_pointer(interaction.guild)
247+
pointer.set_x(1)
248+
await message.edit(embed=discord.Embed(title="Little Game",
249+
description=display(x=pointer.possition_x, y=pointer.possition_y)),
232250
components=[discord.ActionRow(empty_button, arrow_button().set_label('').set_custom_id('up'), empty_button),
233251
discord.ActionRow(arrow_button().set_label('').set_custom_id('left'),
234252
arrow_button().set_label('').set_custom_id('down'),
235253
arrow_button().set_label('').set_custom_id('right').disable_if(pointer.possition_x >= 9))]
236254
)
237-
elif interaction.component.custom_id == "left":
238-
pointer.set_x(-1)
239-
await message.edit(embed=discord.Embed(title="Little Game",
240-
description=display(x=pointer.possition_x, y=pointer.possition_y)),
255+
256+
@client.on_click()
257+
async def left(i: discord.Interaction, button):
258+
pointer: Pointer = get_pointer(interaction.guild)
259+
pointer.set_x(-1)
260+
await message.edit(embed=discord.Embed(title="Little Game",
261+
description=display(x=pointer.possition_x, y=pointer.possition_y)),
241262
components=[discord.ActionRow(empty_button, arrow_button().set_label('').set_custom_id('up'), empty_button),
242263
discord.ActionRow(arrow_button().set_label('').set_custom_id('left').disable_if(pointer.possition_x <= 0),
243264
arrow_button().set_label('').set_custom_id('down'),
244265
arrow_button().set_label('').set_custom_id('right'))]
245-
)
266+
)
267+
268+
Take a look at `the documentation <https://discordpy-message-components.readthedocs.io/en/latest/>`_ to see more examples.

0 commit comments

Comments
 (0)