Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add modals to the quickstart #503

Merged
merged 54 commits into from Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
3ac55f4
refactor methods to use the `MISSING` value
EdVraz Jan 25, 2022
ebc01e3
moved `MISSING` class to other file
EdVraz Jan 25, 2022
db23c34
refactored methods in
EdVraz Jan 25, 2022
65faf42
refactored methods in
EdVraz Jan 25, 2022
e1a6e36
refactored methods in
EdVraz Jan 25, 2022
f49c77d
refactored methods in
EdVraz Jan 25, 2022
0f8025c
refactored methods in
EdVraz Jan 25, 2022
c852e8a
new helper methods:
EdVraz Jan 25, 2022
5f4588a
change purge values to `MISSING`
EdVraz Jan 25, 2022
028e702
Merge branch 'unstable' into helper_methods
EdVraz Jan 25, 2022
34a08b4
new helper methods:
EdVraz Jan 25, 2022
45fa6b9
Merge remote-tracking branch 'origin/helper_methods' into helper_methods
EdVraz Jan 25, 2022
b8b2529
new helper methods:
EdVraz Jan 26, 2022
bc319a0
new helper methods:
EdVraz Jan 26, 2022
1905772
Some work
EdVraz Jan 28, 2022
82d5746
new method:
EdVraz Jan 28, 2022
9f5b326
refactor
EdVraz Jan 29, 2022
8f58d1b
Merge branch 'unstable' into helper_methods
EdVraz Jan 29, 2022
37ab6ee
added `pytz` to requirements.txt
EdVraz Jan 29, 2022
3153c53
Update message.py
EdVraz Jan 29, 2022
a86e950
Merge branch 'unstable' into helper_methods
EdVraz Jan 31, 2022
a4a7944
Update client.py
EdVraz Jan 31, 2022
360b203
remove pytz from requirements
Feb 2, 2022
46de72b
add returns
Feb 2, 2022
0f175a6
new docs
Feb 2, 2022
fbef804
docs: update faq.rst
EdVraz Feb 2, 2022
49ee638
docs: inviting the bot to a guild
EdVraz Feb 2, 2022
06ac727
docs: inviting the bot to a guild
EdVraz Feb 2, 2022
287f950
docs
EdVraz Feb 2, 2022
9759bc8
docs: starting the bot
EdVraz Feb 2, 2022
d7e2a3b
docs: first command
EdVraz Feb 2, 2022
99fbb86
docs: fix typo
EdVraz Feb 2, 2022
514507b
docs: Options
EdVraz Feb 2, 2022
86ca74c
docs: some editing
EdVraz Feb 2, 2022
4075f15
docs: subcommands
EdVraz Feb 2, 2022
942a2c9
docs: fixed typo
EdVraz Feb 2, 2022
d4e4edf
docs:
EdVraz Feb 2, 2022
2387438
docs: add information for required fields
EdVraz Feb 3, 2022
a6778bc
Merge branch 'unstable' into newdocs
EdVraz Feb 3, 2022
576e632
Merge branch 'unstable' into newdocs
EdVraz Feb 7, 2022
e623b03
some work
EdVraz Feb 9, 2022
9925bf1
docs: format admonition
i0bs Feb 9, 2022
ca03038
docs: format admonition
i0bs Feb 9, 2022
f2b8bcb
docs: format admonition
i0bs Feb 9, 2022
635816d
Update docs/quickstart.rst
EdVraz Feb 9, 2022
0c3807e
ci: correct from checks.
pre-commit-ci[bot] Feb 9, 2022
19a4aa9
docs: format admonition
i0bs Feb 9, 2022
516e184
Update docs/quickstart.rst
EdVraz Feb 9, 2022
a842152
Update docs/quickstart.rst
EdVraz Feb 9, 2022
7d945c5
docs: write stuff
EdVraz Feb 9, 2022
520dd49
docs: write stuff
EdVraz Feb 10, 2022
41af9de
docs
EdVraz Feb 10, 2022
fbd74f2
Merge remote-tracking branch 'origin/newdocs' into newdocs
EdVraz Feb 10, 2022
ed73acb
Merge branch 'unstable' into newdocs
EdVraz Feb 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added docs/_static/modal_popup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 55 additions & 4 deletions docs/quickstart.rst
Expand Up @@ -242,12 +242,10 @@ your ``@command`` decorator:
.. important::
The structure of a menu command differs significantly from that of a regular one:


- You cannot have any options or choices.
- You cannot have a description.
- The ``name`` filter follows a different regex pattern.


Creating and sending Components
*******************************

Expand Down Expand Up @@ -293,8 +291,8 @@ What kinds of components are there?

As a bot developer, this may be fairly important for you to want to know.
Different components provide difference user experiences, interactions
and results. Currently you can choose between two components that Discord
provides: a ``Button`` and ``SelectMenu``. You're able to `find these component
and results. Currently you can choose between three components that Discord
provides: a ``Button``, ``SelectMenu`` and ``TextInput``. You're able to `find these component
types`_ here.

How do I send components in a row?
Expand Down Expand Up @@ -332,6 +330,59 @@ method will always support ``ActionRow``-less sending: you only need to declare
rows whenever you need or want to. This field will also support raw arrays and
tables, if you so wish to choose to not use our class objects instead.


.. important:: You cannot use ``TextInput`` with the above shown method.
Look :ref:`here <quickstart:Creating a TextInput>` how to create and send them.


Creating a TextInput
^^^^^^^^^^^^^^^^^^^^
You want to get a Text from a user? You can use ``TextInput``s for that.

.. code-block:: python

interactions.TextInput(
style=interactions.TextStyleType.SHORT,
label="Let's get straight to it: what's 1 + 1?",
custom_id="text_input_response",
min_length=1,
max_length=3,
)

But how to send it? You can't use ``ctx.send`` for it. Take a look at :ref:`Modals <quickstart:Modals>` for that.


Modals
******
Modals are a new way to interact with a user. Currently only a ``TextInput`` component is supported. You can have up to three ``TextInput``s in a Modal.

.. code-block:: python

async def my_cool_modal_command(ctx):
modal = interactions.Modal(
title="Application Form",
custom_id="mod_app_form",
components=[interactions.TextInput(...)],
)

await ctx.popup(modal)

with the ``TextInput`` example from above we get:

.. image:: _static/modal_popup.png

Responding to a Modal interaction
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: python

@bot.modal("mod_app_form")
async def modal_response(ctx, response: str):
await ctx.send(f"You wrote: {response}", ephemeral=True)

You can respond to a modal the same way as you would respond to a normal ``chat-input`` command, except your function has an extra argument for the text what was put into the modal.


.. _Client: https://discord-interactions.rtfd.io/en/stable/client.html
.. _find these component types: https://discord-interactions.readthedocs.io/en/stable/models.component.html
.. _discord applications page: https://discord.com/developers/applications