Skip to content

Commit

Permalink
Document all limits in discord.ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Soheab authored Jan 27, 2024
1 parent 841e915 commit 070ae24
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
8 changes: 3 additions & 5 deletions discord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ class SelectOption:
Can only be up to 100 characters.
value: :class:`str`
The value of the option. This is not displayed to users.
If not provided when constructed then it defaults to the
label. Can only be up to 100 characters.
If not provided when constructed then it defaults to the label.
Can only be up to 100 characters.
description: Optional[:class:`str`]
An additional description of the option, if any.
Can only be up to 100 characters.
Expand All @@ -332,14 +332,12 @@ class SelectOption:
-----------
label: :class:`str`
The label of the option. This is displayed to users.
Can only be up to 100 characters.
value: :class:`str`
The value of the option. This is not displayed to users.
If not provided when constructed then it defaults to the
label. Can only be up to 100 characters.
label.
description: Optional[:class:`str`]
An additional description of the option, if any.
Can only be up to 100 characters.
default: :class:`bool`
Whether this option is selected by default.
"""
Expand Down
4 changes: 4 additions & 0 deletions discord/ui/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@ class Button(Item[V]):
custom_id: Optional[:class:`str`]
The ID of the button that gets received during an interaction.
If this button is for a URL, it does not have a custom ID.
Can only be up to 100 characters.
url: Optional[:class:`str`]
The URL this button sends you to.
disabled: :class:`bool`
Whether the button is disabled or not.
label: Optional[:class:`str`]
The label of the button, if any.
Can only be up to 80 characters.
emoji: Optional[Union[:class:`.PartialEmoji`, :class:`.Emoji`, :class:`str`]]
The emoji of the button, if available.
row: Optional[:class:`int`]
Expand Down Expand Up @@ -258,9 +260,11 @@ def button(
------------
label: Optional[:class:`str`]
The label of the button, if any.
Can only be up to 80 characters.
custom_id: Optional[:class:`str`]
The ID of the button that gets received during an interaction.
It is recommended not to set this parameter to prevent conflicts.
Can only be up to 100 characters.
style: :class:`.ButtonStyle`
The style of the button. Defaults to :attr:`.ButtonStyle.grey`.
disabled: :class:`bool`
Expand Down
3 changes: 2 additions & 1 deletion discord/ui/modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ async def on_submit(self, interaction: discord.Interaction):
Parameters
-----------
title: :class:`str`
The title of the modal. Can only be up to 45 characters.
The title of the modal.
Can only be up to 45 characters.
timeout: Optional[:class:`float`]
Timeout in seconds from last interaction with the UI before no longer accepting input.
If ``None`` then there is no timeout.
Expand Down
22 changes: 21 additions & 1 deletion discord/ui/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,10 @@ class Select(BaseSelect[V]):
custom_id: :class:`str`
The ID of the select menu that gets received during an interaction.
If not given then one is generated for you.
Can only be up to 100 characters.
placeholder: Optional[:class:`str`]
The placeholder text that is shown if nothing is selected, if any.
Can only be up to 150 characters.
min_values: :class:`int`
The minimum number of items that must be chosen for this select menu.
Defaults to 1 and must be between 0 and 25.
Expand All @@ -376,6 +378,7 @@ class Select(BaseSelect[V]):
Defaults to 1 and must be between 1 and 25.
options: List[:class:`discord.SelectOption`]
A list of options that can be selected in this menu.
Can only contain up to 25 items.
disabled: :class:`bool`
Whether the select is disabled or not.
row: Optional[:class:`int`]
Expand Down Expand Up @@ -455,7 +458,8 @@ def add_option(
Can only be up to 100 characters.
value: :class:`str`
The value of the option. This is not displayed to users.
If not given, defaults to the label. Can only be up to 100 characters.
If not given, defaults to the label.
Can only be up to 100 characters.
description: Optional[:class:`str`]
An additional description of the option, if any.
Can only be up to 100 characters.
Expand Down Expand Up @@ -515,8 +519,10 @@ class UserSelect(BaseSelect[V]):
custom_id: :class:`str`
The ID of the select menu that gets received during an interaction.
If not given then one is generated for you.
Can only be up to 100 characters.
placeholder: Optional[:class:`str`]
The placeholder text that is shown if nothing is selected, if any.
Can only be up to 150 characters.
min_values: :class:`int`
The minimum number of items that must be chosen for this select menu.
Defaults to 1 and must be between 0 and 25.
Expand All @@ -527,6 +533,7 @@ class UserSelect(BaseSelect[V]):
Whether the select is disabled or not.
default_values: Sequence[:class:`~discord.abc.Snowflake`]
A list of objects representing the users that should be selected by default.
Number of items must be in range of ``min_values`` and ``max_values``.
.. versionadded:: 2.4
row: Optional[:class:`int`]
Expand Down Expand Up @@ -604,8 +611,10 @@ class RoleSelect(BaseSelect[V]):
custom_id: :class:`str`
The ID of the select menu that gets received during an interaction.
If not given then one is generated for you.
Can only be up to 100 characters.
placeholder: Optional[:class:`str`]
The placeholder text that is shown if nothing is selected, if any.
Can only be up to 150 characters.
min_values: :class:`int`
The minimum number of items that must be chosen for this select menu.
Defaults to 1 and must be between 0 and 25.
Expand All @@ -616,6 +625,7 @@ class RoleSelect(BaseSelect[V]):
Whether the select is disabled or not.
default_values: Sequence[:class:`~discord.abc.Snowflake`]
A list of objects representing the roles that should be selected by default.
Number of items must be in range of ``min_values`` and ``max_values``.
.. versionadded:: 2.4
row: Optional[:class:`int`]
Expand Down Expand Up @@ -688,8 +698,10 @@ class MentionableSelect(BaseSelect[V]):
custom_id: :class:`str`
The ID of the select menu that gets received during an interaction.
If not given then one is generated for you.
Can only be up to 100 characters.
placeholder: Optional[:class:`str`]
The placeholder text that is shown if nothing is selected, if any.
Can only be up to 150 characters.
min_values: :class:`int`
The minimum number of items that must be chosen for this select menu.
Defaults to 1 and must be between 0 and 25.
Expand All @@ -701,6 +713,7 @@ class MentionableSelect(BaseSelect[V]):
default_values: Sequence[:class:`~discord.abc.Snowflake`]
A list of objects representing the users/roles that should be selected by default.
if :class:`.Object` is passed, then the type must be specified in the constructor.
Number of items must be in range of ``min_values`` and ``max_values``.
.. versionadded:: 2.4
row: Optional[:class:`int`]
Expand Down Expand Up @@ -778,10 +791,12 @@ class ChannelSelect(BaseSelect[V]):
custom_id: :class:`str`
The ID of the select menu that gets received during an interaction.
If not given then one is generated for you.
Can only be up to 100 characters.
channel_types: List[:class:`~discord.ChannelType`]
The types of channels to show in the select menu. Defaults to all channels.
placeholder: Optional[:class:`str`]
The placeholder text that is shown if nothing is selected, if any.
Can only be up to 150 characters.
min_values: :class:`int`
The minimum number of items that must be chosen for this select menu.
Defaults to 1 and must be between 0 and 25.
Expand All @@ -792,6 +807,7 @@ class ChannelSelect(BaseSelect[V]):
Whether the select is disabled or not.
default_values: Sequence[:class:`~discord.abc.Snowflake`]
A list of objects representing the channels that should be selected by default.
Number of items must be in range of ``min_values`` and ``max_values``.
.. versionadded:: 2.4
row: Optional[:class:`int`]
Expand Down Expand Up @@ -1011,9 +1027,11 @@ async def select_channels(self, interaction: discord.Interaction, select: Channe
get overridden.
placeholder: Optional[:class:`str`]
The placeholder text that is shown if nothing is selected, if any.
Can only be up to 150 characters.
custom_id: :class:`str`
The ID of the select menu that gets received during an interaction.
It is recommended not to set this parameter to prevent conflicts.
Can only be up to 100 characters.
row: Optional[:class:`int`]
The relative row this select menu belongs to. A Discord component can only have 5
rows. By default, items are arranged automatically into those 5 rows. If you'd
Expand All @@ -1029,6 +1047,7 @@ async def select_channels(self, interaction: discord.Interaction, select: Channe
options: List[:class:`discord.SelectOption`]
A list of options that can be selected in this menu. This can only be used with
:class:`Select` instances.
Can only contain up to 25 items.
channel_types: List[:class:`~discord.ChannelType`]
The types of channels to show in the select menu. Defaults to all channels. This can only be used
with :class:`ChannelSelect` instances.
Expand All @@ -1037,6 +1056,7 @@ async def select_channels(self, interaction: discord.Interaction, select: Channe
default_values: Sequence[:class:`~discord.abc.Snowflake`]
A list of objects representing the default values for the select menu. This cannot be used with regular :class:`Select` instances.
If ``cls`` is :class:`MentionableSelect` and :class:`.Object` is passed, then the type must be specified in the constructor.
Number of items must be in range of ``min_values`` and ``max_values``.
.. versionadded:: 2.4
"""
Expand Down
6 changes: 6 additions & 0 deletions discord/ui/text_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,27 @@ class TextInput(Item[V]):
------------
label: :class:`str`
The label to display above the text input.
Can only be up to 45 characters.
custom_id: :class:`str`
The ID of the text input that gets received during an interaction.
If not given then one is generated for you.
Can only be up to 100 characters.
style: :class:`discord.TextStyle`
The style of the text input.
placeholder: Optional[:class:`str`]
The placeholder text to display when the text input is empty.
Can only be up to 100 characters.
default: Optional[:class:`str`]
The default value of the text input.
Can only be up to 4000 characters.
required: :class:`bool`
Whether the text input is required.
min_length: Optional[:class:`int`]
The minimum length of the text input.
Must be between 0 and 4000.
max_length: Optional[:class:`int`]
The maximum length of the text input.
Must be between 1 and 4000.
row: Optional[:class:`int`]
The relative row this text input 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

0 comments on commit 070ae24

Please sign in to comment.