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[, 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 embed used for the form’s embeds.

set_timeout(timeout)

Sets the timeout for the form.

start([channel])

Starts the form in the current channel.

add_question(question, qtype=None) → List[dict][source]

Adds a question to the form.

Parameters
  • question (str) – The question as a string that should be added.

  • 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

async set_color(color: discord.colour.Colour) → None[source]

Sets the color of the embed used for the form’s embeds.

Parameters

color (discord.Color) – The color to be used.

Raises

InvalidColor – Is raised if the color is invalid or incorrect.

set_timeout(timeout: int) → None[source]

Sets the timeout for the form.

Parameters

(int) (timeout) –

async start(channel=None) → List[dict][source]

Starts the form in the current channel.

Parameters

channel (discord.TextChannel, optional) – The channel to open the form in. If none, it is gotten from the context object set during initialization.

Returns

[description]

Return type

List[dict]

exception discord.ext.forms.form.InvalidColor[source]

Bases: Exception

exception discord.ext.forms.form.InvalidFormType[source]

Bases: Exception

The exception raised when a form type is invalid.

forms.reactions module

exception discord.ext.forms.reactions.InvalidColor[source]

Bases: Exception

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.

set_color(color)

Sets the color of the form embeds.

start()

Starts the form in the specified channel.

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)

async set_color(color: str) → None[source]

Sets the color of the form embeds.

set_timeout(timeout: int) → None[source]
async start() → dict[source]

Starts the form in the specified channel. If none is specified, the channel will be fetched from the context parameter of the form’s initialization.

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.

start

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

async start(channel=None)[source]