forms.form module¶
-
class
discord.ext.forms.form.
Form
(ctx: discord.ext.commands.context.Context, title)[source]¶ Bases:
object
The basic form object.
Methods
add_question
(question[, key, qtype])Adds a question to the form.
edit_and_delete
([choice])Toggles the edit and delete feature.
set_color
(color)Sets the color of the form embeds.
set_incorrect_message
(message)Sets the message to send if input validation fails and there are no more tries left..
set_retry_message
(message)Sets the message to send if input validation fails.
set_timeout
(timeout)Sets the timeout for the form.
start
([channel])Starts the form in the current channel.
set_tries
validate_input
-
add_question
(question, key: Optional[str] = None, qtype=None) → List[dict][source]¶ Adds a question to the form.
- Parameters
question (str) – The question as a string that should be added.
key (str, optional) – The prefered key to be used. If none, defaults to the to the question. By default None.
qtype (str, optional) – The input validation to be used (incomplete), by default None
- Returns
A list of all of the questions, stored as dictionaries.
- Return type
List[dict]
- Raises
InvalidFormType – Is raised when the input validation type is invalid.
-
edit_and_delete
(choice: Optional[bool] = None) → bool[source]¶ Toggles the edit and delete feature.
- Parameters
choice (bool, optional) – Whether you want the bot to edit the prompt and delete the input or not. If none, it toggles. The default for edit and delete is off. Default input is None
- Returns
The state of edit and delete (after this is completed)
- Return type
bool
-
set_incorrect_message
(message: str)[source]¶ Sets the message to send if input validation fails and there are no more tries left..
- Parameters
message (str) – The message to be set.
-
set_retry_message
(message: str)[source]¶ Sets the message to send if input validation fails.
- Parameters
message (str) – The message to be set.
-
set_timeout
(timeout: int) → None[source]¶ Sets the timeout for the form.
- Parameters
(int) (timeout) –
-
forms.reactions module¶
-
class
discord.ext.forms.reactions.
ReactionForm
(message: discord.message.Message, bot: Union[discord.client.Client, discord.ext.commands.bot.Bot], user: Optional[Union[discord.member.Member, discord.user.User]] = None)[source]¶ Bases:
object
The Reaction input object.
…
- Parameters
message (discord.Message) – The message of the reaction form object.
bot (typing.Union[discord.Client, discord.ext.commands.Bot]) – The bot being used for the form.
user (typing.Union[discord.Member, discord.User]) – The member or user who should be able to use the form. If none, the form will be open to anyone.
Methods
add_reaction
(reaction, result)Adds a question to the form.
start
()Starts the reaction form on the given message.
set_timeout
-
add_reaction
(reaction: discord.emoji.Emoji, result) → dict[source]¶ Adds a question to the form.
Returns the full list of questions the form has, including the newly added one. The questions are held in dictionaries containing the question and optionally type keys. The question key contains the question as a string, and the type key contains the input validation (if any is specified)
-
class
discord.ext.forms.reactions.
ReactionMenu
(ctx: discord.ext.commands.context.Context, embeds: List[discord.embeds.Embed])[source]¶ Bases:
object
Methods
addemoji
(emoji, page)Adds an emoji/page mapping to your menu.
remove_reactions
([bool])Sets whether the bot should remove reactions or not.
start
([channel])Starts the menu in the given channel.
set_timeout
-
addemoji
(emoji: str, page: int) → bool[source]¶ Adds an emoji/page mapping to your menu.
- Parameters
emoji (str) – The emoji to be used as a string. Custom emoji are supported.
page (int) – The page to be mapped. Uses normal indexing (e.g. 1 is the first page)
- Returns
The result of the emoji being added. False means an error occurred (most likely you tried to add an emoji that was already set) and True means that everything was successful.
- Return type
bool
-
remove_reactions
(bool: bool = True)[source]¶ Sets whether the bot should remove reactions or not. Useful if the bot doesn’t have Manage Messages
- Parameters
choice (bool, optional) – Whether to remove reactions or not., by default True
-
async
start
(channel=None)[source]¶ Starts the menu in the given channel.
- Parameters
channel (discord.TextChannel, optional) – The channel to send the menu to. If none is specified, it uses the context’s channel object.
- Returns
- Return type
None
- Raises
TypeError – If channel isn’t specified and ctx wasn’t set on initialization, the form cannot continue.
-