Skip to content

Commit 38846d8

Browse files
authored
Uploadet docs to main-branch
1 parent 7bd62a4 commit 38846d8

37 files changed

+19133
-0
lines changed

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
52.7 KB
Binary file not shown.

docs/_build/doctrees/index.doctree

14.5 KB
Binary file not shown.
41.3 KB
Binary file not shown.
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
.. discord.py-message-components documentation master file, created by
2+
sphinx-quickstart on Sat Jun 26 14:55:47 2021.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Components
7+
==========
8+
9+
:class:`discord.ActionRow(*args, **kwargs)`
10+
___________________________________________
11+
12+
Represents an ``ActionRow``-Part for the components of an :class:`discord.Message`
13+
14+
Attributes
15+
----------
16+
17+
* :attr:`*args`: [Union[:class:`Button`, :class:`SelectionMenu`]]
18+
An array of :class:`Button`(s) and/or :class:`SelectionMenu`(s).
19+
20+
* :attr:`force`: Optional[Bool]
21+
When set to ``True`` an Empty :class:`ActionRow` will be ignored
22+
23+
.. note::
24+
For more information about ActionRow's visit the `Discord-API Documentation <https://discord.com/developers/docs/interactions/message-components#actionrow>`_.
25+
26+
Methodes
27+
--------
28+
29+
:meth:`sendable`: Dict
30+
Makes the :class:`ActionRow` sendable to discord.
31+
32+
:meth:`disable_all_buttons()`
33+
Disable all objects's of type :class:`discord.Button` in this :class:`ActionRow`.
34+
35+
:return: :class:`discord.ActionRow`
36+
37+
:meth:`disable_all_buttons_if(check: Union[Bool, Callable], **kwargs)`
38+
Disable all :class:`discord.Button` in this :class:`ActionRow` if the passed :attr:`check` ``True``.
39+
40+
**Parameters**
41+
42+
* :attr:`check`: Union[Bool, Callable]
43+
could be an :class:`bool` or usually any :obj:`Callable` that returns an :class:`bool`
44+
45+
* :attr:`**kwargs`
46+
:obj:`kwargs` that should passed in to the :attr:`check` if it is an :obj:`Callable`
47+
48+
:return: :class:`ActionRow`
49+
50+
:class:`discord.Button(**kwargs)`
51+
_________________________________
52+
53+
Represents an ``Discord-Button``
54+
55+
.. note::
56+
For more information Discord-Button's visit the `Discord-API Documentation <https://discord.com/developers/docs/interactions/message-components#buttons>`_.
57+
58+
Attributes
59+
----------
60+
61+
:attr:`label`: :class:`str`
62+
The Text displayed in discord on the Button. Maximal lenght is 80 Chars.
63+
:attr:`custom_id`: Union[:class:`str`, :class:`int`]
64+
The custom_id discord send us when a User press the Button. The max. lenght of this is 100.
65+
:attr:`style`: Union[:class:`ButtonColor`, :class:`ButtonStyle`, Any[1, 2, 3, 4, 5]]
66+
The Style of the Button.
67+
68+
.. note::
69+
To get more infos about the styles visit
70+
`the Discord-API Documentation <https://discord.com/developers/docs/interactions/message-components#buttons-button-styles>`_.
71+
72+
:attr:`emoji`: Optional[Union[:class:`discord.PartialEmoji`, :class:`discord.Emoji`, :class:`str`]]
73+
The Emoji that will be displayed on the left side of the Button.
74+
75+
:attr:`url`: Optional[:class:`str`]
76+
The url the Button includes
77+
78+
.. note::
79+
if you set this, the :attr:`style` will automaticly set to :class:`ButtonStyle.Link_Button`
80+
81+
.. warning::
82+
83+
You cant pass an :attr:`custom_id` and a :attr:`url` beacuse discord dont send anything when clicking on an ``URL-Button`` so it dont accept both; :attr:`url`/ButtonStyle.Link_Button and :attr:`custom_id`!
84+
85+
:attr:`disabled`: :class:`Bool`
86+
Whether the Button is disabled; defauld False.
87+
88+
89+
Methodes
90+
--------
91+
92+
:meth:`disable_if`
93+
Disable the :class:`Button` if the passed :attr:`check` returns ``True``.
94+
95+
- :attr:`check`: typing.Union[bool, typing.Callable]
96+
Could be an :class:`bool` or usually any :class:`Callable` that returns an :class:`bool`
97+
98+
- :attr:`**kwargs`: Any[SupportsIndex]
99+
Arguments that should passed in to the :attr:`check` if it is an :class:`Callable`
100+
101+
:return: :class:`discord.Button`
102+
103+
:meth:`set_color_if`
104+
Sets the Color(Style) of an :class:`discord.Button` to the provided :attr:`color` if the passed :attr:`check` returns ``True``.
105+
106+
- :attr:`check`: could be an :class:`bool` or usaly any :obj:`Callable` that returns an :class:`bool`
107+
108+
- :attr:`color`: the Color(Style) that should set if the :attr:`check` returns ``True``
109+
110+
- :attr:`**kwargs`: ``kwargs`` that should passed in to the :attr:`check` if it is an :class:`Callable`
111+
112+
:return: :class:`discord.Button`
113+
114+
.. toctree::
115+
:maxdepth: 2
116+
:caption: Contents: index.rst, interaction.rst
117+
118+
Indices and tables
119+
==================
120+
121+
* :ref:`genindex`
122+
* :ref:`modindex`
123+
* :ref:`search`
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
.. discord.py-message-components documentation master file, created by
2+
sphinx-quickstart on Sat Jun 26 14:55:47 2021.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Welcome to discord.py-message-component's documentation!
7+
=========================================================
8+
9+
.. toctree::
10+
:maxdepth: 3
11+
:caption: Contents:
12+
13+
index.rst
14+
interaction.rst
15+
components.rst
16+
17+
Installing:
18+
___________
19+
20+
**Python 3.5.3 or higher is required**
21+
22+
first uninstall the original `discord.py <https://pypi.org/project/discord.py>`_ Library:
23+
24+
.. code:: sh
25+
26+
# Linux/macOS
27+
python3 -m pip uninstall discord.py
28+
29+
# Windows
30+
py -3 -m pip uninstall discord.py
31+
32+
then install `this Library <https://pypi.org/project/discord.py-message-components>`_ using:
33+
34+
.. code:: sh
35+
36+
# Linux/macOS
37+
python3 -m pip install -U discord.py-message-components
38+
39+
# Windows
40+
py -3 -m pip install -U discord.py-message-components
41+
42+
43+
44+
quickstart
45+
__________
46+
47+
sending-buttons
48+
~~~~~~~~~~~~~~~~
49+
50+
.. code-block:: python
51+
52+
import discord
53+
from discord.ext import commands
54+
from discord.components import Button, ButtonColor
55+
56+
57+
client = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
58+
59+
60+
@client.command()
61+
async def buttons(ctx):
62+
await ctx.send('Hey here are some Buttons', components=[[
63+
Button(label="Hey i\'m a red Button",
64+
custom_id="this is an custom_id",
65+
style=ButtonColor.red),
66+
Button(label="Hey i\'m a green Button",
67+
custom_id="this is an custom_id",
68+
style=ButtonColor.green),
69+
Button(label="Hey i\'m a blue Button",
70+
custom_id="this is an custom_id",
71+
style=ButtonColor.blurple),
72+
Button(label="Hey i\'m a grey Button",
73+
custom_id="this is an custom_id",
74+
style=ButtonColor.grey),
75+
Button(label="Hey i\'m a URL Button",
76+
url="https://pypi.org/project/discord.py-message-components",
77+
style=ButtonColor.grey_url)
78+
]])
79+
80+
client.run('Your Bot-Token')
81+
82+
83+
respond to an button when he pressed by a user
84+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85+
86+
.. code-block:: python
87+
88+
import discord
89+
from discord.ext import commands
90+
from discord.components import Button, ButtonColor
91+
92+
93+
client = commands.Bot(command_prefix=commands.when_mentioned_or('!'))
94+
95+
96+
@client.command()
97+
async def buttons(ctx):
98+
msg_with_buttons = await ctx.send('Hey here are some Buttons', components=[[
99+
Button(label="Hey i\'m a red Button",
100+
custom_id="red",
101+
style=ButtonColor.red),
102+
Button(label="Hey i\'m a green Button",
103+
custom_id="green",
104+
style=ButtonColor.green),
105+
Button(label="Hey i\'m a blue Button",
106+
custom_id="blue",
107+
style=ButtonColor.blurple),
108+
Button(label="Hey i\'m a grey Button",
109+
custom_id="grey",
110+
style=ButtonColor.grey)
111+
]])
112+
113+
def check_button(i: discord.Interaction, b: discord.ButtonClick):
114+
return i.author == ctx.author and i.message == msg_with_buttons
115+
116+
interaction, button = await client.wait_for('button_click', check=check_button)
117+
118+
embed = discord.Embed(title='You pressed an Button',
119+
description=f'You pressed a {button.custom_id} button.',
120+
color=discord.Color.random())
121+
await interaction.respond(embed=embed)
122+
123+
client.run('Your Bot-Token')
124+
125+
.. note::
126+
You could set the Paramerter ``hidden`` in the respond to True, to make the Message ephemeral.
127+
.. seealso:: `discord.Interaction.respond <./interaction.html#respond>`_
128+
129+
130+
131+
132+
133+
Indices and tables
134+
==================
135+
136+
* :ref:`genindex`
137+
* :ref:`modindex`
138+
* :ref:`search`
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
.. discord.py-message-components documentation master file, created by
2+
sphinx-quickstart on Sat Jun 26 14:55:47 2021.
3+
You can adapt this file completely to your liking, but it should at least
4+
contain the root `toctree` directive.
5+
6+
Interaction
7+
===========
8+
9+
10+
:class:`discord.Interaction`
11+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
13+
Represents an interaction createt in discord like click an :class:`discord.Button` or select an option of :class:`discord.SelectionMenu`
14+
15+
.. note::
16+
For more informations about Interactions visit the Documentation of the `Discord-API <https://discord.com/developers/docs/interactions/slash-commands#interaction-object>`_
17+
18+
.. warning::
19+
Do not initiate this Class manually
20+
21+
Attributes
22+
__________
23+
:attr:`author`: :class:`discord.abc.User`
24+
A :class:`Member` that invoked the interaction. If :attr:`channel` is a
25+
private channel or the user has left the guild, then it is a :class:`User` instead.
26+
:attr:`message`: :class:`discord.Message`
27+
The message the component was attachet to.
28+
This will be equal to ``None`` if the :attr:`component_type` is ``None`` or the message the component is attached to is ``emphemberal``.
29+
30+
.. note::
31+
In this version, this parameter should alwasys be an object of type :class:`discord.Message`
32+
(or ``None`` if the message is emphemberal) beacuse it only gets initiatet when the interaction_type is highter than 2
33+
34+
:attr:`channel`: Union[:class:`discord.TextChannel`, :class:`discord.DMChannel`]
35+
The Channel the interaction was createt in this is aiter an object of :class:`discord.TextChannel` if it's
36+
inside a guild else it's an object of type :class:`discord.DMChannel`.
37+
:attr:`guild`: Union[:class:`discord.Guild`, :class:`None`]
38+
The guild asotiatet with the interaction; aiter an object of type :class:`discord.Guild`,
39+
except the interaction was inside an dm-channel then this would be equal to ``None``
40+
:attr:`component`: Union[:class:`ButtonClick`, :class:`SelectionSelect`]
41+
The component that invoked this interaction: Aiter an object of type :class:`ButtonClick` or :class:`SelectionSelect`
42+
43+
.. note::
44+
If this is passed in an ``[on_]button_click`` or ``[on_]selection_select`` Event there wuild be a second parameter that includes this attribute.
45+
46+
Methodes
47+
________
48+
49+
:meth:`defer`: None
50+
'Defers' the response, showing a loading state to the use.
51+
52+
.. warning::
53+
If you dont respond with an message using :meth:`respond`
54+
or edit the original message using :meth:`edit` within less than 3 seconds,
55+
discord will indicates that the interaction failed and the interaction-token will be invalidated.
56+
To provide this us this method
57+
58+
.. note::
59+
A Token will be Valid for 15 Minutes so you could edit the original :attr:`message` with :meth:`edit`, :meth:`respond` or doing anything other with this interaction for 15 minutes.
60+
After that time you have to edit the original message with the Methode :meth:`edit` of the :attr:`message` and sending new messages with the :meth:`send` Methode of :attr:`channel`
61+
(you could not do this hidden as it isn't an respond anymore and also you could not pass more than one :class:`Embed`)
62+
63+
:meth:`respond`: Union[:class:`discord.Message`, :class:`discord.EphemeralMessage`]
64+
You could pass the same Paramerts as using :meth:`discord.Messageable.send` but there are two more optional:
65+
66+
* :attr:`embeds` Optional[List[discord.Embed]]
67+
An :class:`list` containing up to 10 Embeds that should send with the respond.
68+
* :attr:`hidden` Optional[Bool]
69+
If set to ``True``, the message will be only vible for the :attr:`author` of the Interaction and will disapears if the :attr:`author` click on ``delete this message`` or reloads the client.
70+
71+
.. note::
72+
If you send an ``hidden`` (emphemberal)-respond, discord dont returns any data like an message you could edit,
73+
**but** you could resive Interactions when the Author interact with an component
74+
75+
Responds to an interaction by sending a message that can be made visible only to the person who invoked the interaction by setting the :attr:`hidden` to ``True``.
76+
77+
.. toctree::
78+
:maxdepth: 2
79+
:caption: Contents: index.rst, interaction.rst
80+
81+
Indices and tables
82+
==================
83+
84+
* :ref:`genindex`
85+
* :ref:`modindex`
86+
* :ref:`search`

0 commit comments

Comments
 (0)