Skip to content

Commit

Permalink
Merge pull request Pycord-Development#1066 from krittick/modal-docs
Browse files Browse the repository at this point in the history
Add and update docstrings for `Modal` and `InputText` objects and related methods
  • Loading branch information
krittick authored Feb 21, 2022
2 parents 4c318f5 + 8fc8d1c commit 5f18e65
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
16 changes: 16 additions & 0 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,22 @@ async def send_autocomplete_result(
self._responded = True

async def send_modal(self, modal: Modal):
"""|coro|
Responds to this interaction by sending a modal dialog.
This cannot be used to respond to another modal dialog submission.
Parameters
----------
modal: :class:`discord.ui.Modal`
The modal dialog to display to the user.
Raises
------
HTTPException
Sending the modal failed.
InteractionResponded
This interaction has already been responded to before.
"""
if self._responded:
raise InteractionResponded(self._parent)

Expand Down
6 changes: 5 additions & 1 deletion discord/ui/input_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,21 @@ class InputText:
The ID of the input text field that gets received during an interaction.
label: Optional[:class:`str`]
The label for the input text field, if any.
Must be 45 characters or fewer.
placeholder: Optional[:class:`str`]
The placeholder text that is shown if nothing is selected, if any.
Must be 100 characters or fewer.
min_length: Optional[:class:`int`]
The minimum number of characters that must be entered.
Defaults to 0.
Defaults to 0 and must be less than 4000.
max_length: Optional[:class:`int`]
The maximum number of characters that can be entered.
Must be between 1 and 4000.
required: Optional[:class:`bool`]
Whether the input text field is required or not. Defaults to `True`.
value: Optional[:class:`str`]
Pre-fills the input text field with this value.
Must be 4000 characters or fewer.
row: Optional[:class:`int`]
The relative row this button belongs to. A Discord component can only have 5
rows. By default, items are arranged automatically into those 5 rows. If you'd
Expand Down
8 changes: 8 additions & 0 deletions discord/ui/modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ class Modal:
"""Represents a UI Modal dialog.
This object must be inherited to create a UI within Discord.
Parameters
----------
title: :class:`str`
The title of the modal dialog.
Must be 45 characters or fewer.
custom_id: Optional[:class:`str`] = None
The ID of the modal dialog that gets received during an interaction.
"""

def __init__(self, title: str, custom_id: Optional[str] = None) -> None:
Expand Down

0 comments on commit 5f18e65

Please sign in to comment.