ActionRow
- class discord.ActionRow
Bases:
Generic[T]Represents an ActionRow-Part for the components of a
MessageorModal.- components
The components the
ActionRowholds. This could be up to fiveButton, one Select like object or oneTextInput.
Represents an ActionRow-Part for the components of a
Message.- Parameters:
*components (Union[
Button, Select,TextInput]) – This could be up to fiveButton, one Select like object or oneTextInput.
- add_component(component)
Adds a component to the
ActionRowand returns itself.
- insert_component_at(index, component)
Inserts a component before a specified index to the
ActionRowand returns itself.
- set_component_at(index, component)
Modifies a component to the
ActionRowand returns itself.Note
The index must point to a valid pre-existing component.
- disable_component_at(index)
Disables the component at the specified position of the
ActionRowand returns itself.- Parameters:
index (
int) – The position of the component to be deactivated in the ActionRow.- Raises:
IndexError – The specified index is outside the length of the actionRow.
- Returns:
The updated instance
- Return type:
- add_components(*components)
Adds multiple components to the
ActionRowand returns itself.
- disable_all_components()
Disables all components in this
ActionRowand returns itself.- Returns:
The updated instance
- Return type:
- disable_all_components_if(check, *args, **kwargs)
Disables all
componentsin thisActionRowif the passedcheckreturnsTrueand returns itself.- Parameters:
check (Union[
bool, Callable[[Any, …],bool]]) – Could be anboolor usually anyCallablethat returns abool*args (Any) – Positional arguments that should be passed in to the
checkif it is aCallable**kwargs (Any) – Keyword-only arguments that should be passed in to the
checkif it is aCallable
- Returns:
The updated instance
- Return type:
- disable_all_buttons()
Disables any
Buttonin thisActionRowand returns itself.- Returns:
The updated instance
- Return type:
- disable_all_buttons_if(check, *args, **kwargs)
Disables any
Buttonin thisActionRowif the passedcheckreturnsTrueand returns itself.- Parameters:
check (Union[
bool, Callable[[Any, …],bool]]) – Could be anboolor usually anyCallablethat returns abool*args (Any) – Positional arguments that should be passed in to the
checkif it is aCallable**kwargs (Any) – Keyword-only arguments that should be passed in to the
checkif it is aCallable
- Returns:
The updated instance
- Return type:
Disables all Select like objects in this
ActionRowand returns itself.- Returns:
The updated instance
- Return type:
Disables all Select like objects in this
ActionRowif the passedcheckreturnsTrueand returns itself.- Parameters:
check (Union[
bool, Callable[[Any, …],bool]]) – Could be anboolor usually anyCallablethat returns abool*args (Any) – Positional arguments that should be passed in to the
checkif it is aCallable**kwargs (Any) – Keyword-only arguments that should be passed in to the
checkif it is aCallable
- Returns:
The updated instance
- Return type:
SelectOption
- class discord.SelectOption
Bases:
objectA class that represents an option for a
SelectMenu- description
an additional description of the option, max 50 characters
- Type:
Optional[
str] = None
- emoji
an Emoji that will be shown on the left side of the option.
- Type:
Union[
PartialEmoji,Emoji,str] = None
- default
will render this option as selected by default
- Type:
Optional[
bool] = False
- Raises:
ValueError – One of
label,valueordescriptionis too long.
SelectDefaultValue
- class discord.SelectDefaultValue
Bases:
objectA default value for a
UserSelect,RoleSelect,MentionableSelectorChannelSelectNote
As all of those select types except
MentionableSelectaccept only one type of value, you can for those just use instances of the mentioned type or aint/str/discord.Objectand the library will convert them to default values for you. However, this might be slower than just providing instances of this class.- Parameters:
id (Union[
int,str,discord.Object]) – The ID of a user, role, or channeltype (Optional[
SelectDefaultValueType]) – The type of the value thatidrepresents. If not passed, it will be tried to be inferred from the type ofid. (Must be not an int/str then)
UserSelect
- defdisable_if
- defset_custom_id
- class discord.UserSelect
Bases:
BaseSelectVery similar to
SelectMenubut you can select from a list ofMember/UserNote
optionscan’t be set for this type. But you can setdefault_valuesto a list ofMember/Userto set the default values.See also
- property default_values
A list of values to select by default, must be within the range of
min_valuesandmax_values- Type:
List[
SelectDefaultValue]
- values
The members/users that were selected
Note
This only exists if the
UserSelectis passed as a parameter in an interaction.
- property custom_id
Union[
str,int] (depending on whether it is completely numeric or not):A developer defined ID for this component. This must be unique per
Message/ModalMax. 100 characters long.Note
The custom ID is a good place to store any additional data. For example if you want to make a check in the callback whether the author is a specific user just store the user-id in the custom_id like
# The custom_id custom_id=f'some-prefix:{ctx.author.id}' # Now you can extract this information again in the callback by splitting it at the separator. _, author_id = custom_id.split(':') # Note that the author_id is still a string here, not an integer!
Of course, you can store any and as much data in it as you want. (As long as it does not exceed the max. length)
- disable_if(check, *args, **kwargs)
Disables the Select if the passed
checkreturnsTrueand returns itself.- Parameters:
check (Union[
bool, Callable[[Any, …],bool]]) – Could be anboolor usually anyCallablethat returns abool*args (Any) – Positional arguments that should be passed in to the
checkif it is aCallable**kwargs (Any) – Keyword-only arguments that should be passed in to the
checkif it is aCallable
- Returns:
The updated instance
- Return type:
Union[
SelectMenu,UserSelect,RoleSelect,MentionableSelect,ChannelSelect]
- property disabled
Whether this component can be used or not. If
Trueit is greyed out in the client.- Type:
- property min_values
The minimum number of items that must be chosen; default 1, min. 0, max. 25.
- Type:
- property placeholder
Custom placeholder text if nothing is selected, max. 100 characters.
- Type:
Optional[
str]
- set_custom_id(custom_id)
Set the custom_id of the Select
- Parameters:
custom_id (Union[
str,int]) – The custom_id to replace the old one with- Returns:
The instance with the updated custom_id
- Return type:
Union[
SelectMenu,UserSelect,RoleSelect,MentionableSelect,ChannelSelect]
RoleSelect
- defdisable_if
- defset_custom_id
- class discord.RoleSelect
Bases:
BaseSelectVery similar to
SelectMenubut you can select from a list ofRoleNote
optionscan’t be set for this type. But you can setdefault_valuesto a list ofRoleto set the default values.See also
- property default_values
A list of roles to select by default, must be within the range of
min_valuesandmax_values- Type:
List[
SelectDefaultValue]
- values
The roles that were selected
Note
This only exists if the
RoleSelectis passed as a parameter in an interaction.- Returns:
A list of selected roles
- Return type:
List[
Role]
- property custom_id
Union[
str,int] (depending on whether it is completely numeric or not):A developer defined ID for this component. This must be unique per
Message/ModalMax. 100 characters long.Note
The custom ID is a good place to store any additional data. For example if you want to make a check in the callback whether the author is a specific user just store the user-id in the custom_id like
# The custom_id custom_id=f'some-prefix:{ctx.author.id}' # Now you can extract this information again in the callback by splitting it at the separator. _, author_id = custom_id.split(':') # Note that the author_id is still a string here, not an integer!
Of course, you can store any and as much data in it as you want. (As long as it does not exceed the max. length)
- disable_if(check, *args, **kwargs)
Disables the Select if the passed
checkreturnsTrueand returns itself.- Parameters:
check (Union[
bool, Callable[[Any, …],bool]]) – Could be anboolor usually anyCallablethat returns abool*args (Any) – Positional arguments that should be passed in to the
checkif it is aCallable**kwargs (Any) – Keyword-only arguments that should be passed in to the
checkif it is aCallable
- Returns:
The updated instance
- Return type:
Union[
SelectMenu,UserSelect,RoleSelect,MentionableSelect,ChannelSelect]
- property disabled
Whether this component can be used or not. If
Trueit is greyed out in the client.- Type:
- property min_values
The minimum number of items that must be chosen; default 1, min. 0, max. 25.
- Type:
- property placeholder
Custom placeholder text if nothing is selected, max. 100 characters.
- Type:
Optional[
str]
- set_custom_id(custom_id)
Set the custom_id of the Select
- Parameters:
custom_id (Union[
str,int]) – The custom_id to replace the old one with- Returns:
The instance with the updated custom_id
- Return type:
Union[
SelectMenu,UserSelect,RoleSelect,MentionableSelect,ChannelSelect]
MentionableSelect
- defdisable_if
- defset_custom_id
- class discord.MentionableSelect
Bases:
BaseSelectVery similar to
SelectMenubut you can select from a list of bothMember/UserandRoleNote
optionscan’t be set for this type. But you can setdefault_valuesto a list ofMember/User/Roleto set the default values.See also
- property default_values
A list of values to select by default, must be within the range of
min_valuesandmax_values- Type:
List[
SelectDefaultValue]
- values
The members/users and roles that were selected
Note
This only exists if the
MentionableSelectis passed as a parameter in an interaction.
- property custom_id
Union[
str,int] (depending on whether it is completely numeric or not):A developer defined ID for this component. This must be unique per
Message/ModalMax. 100 characters long.Note
The custom ID is a good place to store any additional data. For example if you want to make a check in the callback whether the author is a specific user just store the user-id in the custom_id like
# The custom_id custom_id=f'some-prefix:{ctx.author.id}' # Now you can extract this information again in the callback by splitting it at the separator. _, author_id = custom_id.split(':') # Note that the author_id is still a string here, not an integer!
Of course, you can store any and as much data in it as you want. (As long as it does not exceed the max. length)
- disable_if(check, *args, **kwargs)
Disables the Select if the passed
checkreturnsTrueand returns itself.- Parameters:
check (Union[
bool, Callable[[Any, …],bool]]) – Could be anboolor usually anyCallablethat returns abool*args (Any) – Positional arguments that should be passed in to the
checkif it is aCallable**kwargs (Any) – Keyword-only arguments that should be passed in to the
checkif it is aCallable
- Returns:
The updated instance
- Return type:
Union[
SelectMenu,UserSelect,RoleSelect,MentionableSelect,ChannelSelect]
- property disabled
Whether this component can be used or not. If
Trueit is greyed out in the client.- Type:
- property min_values
The minimum number of items that must be chosen; default 1, min. 0, max. 25.
- Type:
- property placeholder
Custom placeholder text if nothing is selected, max. 100 characters.
- Type:
Optional[
str]
- set_custom_id(custom_id)
Set the custom_id of the Select
- Parameters:
custom_id (Union[
str,int]) – The custom_id to replace the old one with- Returns:
The instance with the updated custom_id
- Return type:
Union[
SelectMenu,UserSelect,RoleSelect,MentionableSelect,ChannelSelect]
ChannelSelect
- defdisable_if
- defset_custom_id
- class discord.ChannelSelect
Bases:
BaseSelectVery similar to
SelectMenubut you can select from a list of channels.For this type there is an additional parameter
channel_typeswhich can be a list ofChannelType(or the type itself likeTextChannelorStageChannel) that specify from what channel types the user could choose.Note
optionscan’t be set for this type. But you can setdefault_valuesto a list of channels to set as the default values.See also
- property custom_id
Union[
str,int] (depending on whether it is completely numeric or not):A developer defined ID for this component. This must be unique per
Message/ModalMax. 100 characters long.Note
The custom ID is a good place to store any additional data. For example if you want to make a check in the callback whether the author is a specific user just store the user-id in the custom_id like
# The custom_id custom_id=f'some-prefix:{ctx.author.id}' # Now you can extract this information again in the callback by splitting it at the separator. _, author_id = custom_id.split(':') # Note that the author_id is still a string here, not an integer!
Of course, you can store any and as much data in it as you want. (As long as it does not exceed the max. length)
- disable_if(check, *args, **kwargs)
Disables the Select if the passed
checkreturnsTrueand returns itself.- Parameters:
check (Union[
bool, Callable[[Any, …],bool]]) – Could be anboolor usually anyCallablethat returns abool*args (Any) – Positional arguments that should be passed in to the
checkif it is aCallable**kwargs (Any) – Keyword-only arguments that should be passed in to the
checkif it is aCallable
- Returns:
The updated instance
- Return type:
Union[
SelectMenu,UserSelect,RoleSelect,MentionableSelect,ChannelSelect]
- property disabled
Whether this component can be used or not. If
Trueit is greyed out in the client.- Type:
- property min_values
The minimum number of items that must be chosen; default 1, min. 0, max. 25.
- Type:
- property placeholder
Custom placeholder text if nothing is selected, max. 100 characters.
- Type:
Optional[
str]
- set_custom_id(custom_id)
Set the custom_id of the Select
- Parameters:
custom_id (Union[
str,int]) – The custom_id to replace the old one with- Returns:
The instance with the updated custom_id
- Return type:
Union[
SelectMenu,UserSelect,RoleSelect,MentionableSelect,ChannelSelect]
- property default_values
List[
GuildChannel]: A list of channels to select by default, must be within the range ofmin_valuesandmax_values
- values
The channels that were selected
Note
This only exists if the
ChannelSelectis passed as a parameter in an interaction.- Returns:
A list of selected channels
- Return type:
List[Union[
GuildChannel,Messageable]]
Modal
TextInput
- class discord.TextInput
Bases:
BaseComponentRepresents a TextInput
- Parameters:
custom_id (Optional[Union[
str,int]]) – A developer-defined identifier for the input, max 100 charactersstyle (Optional[Union[
TextInputStyle,int]] = TextInputStyle.short) – The Style of the TextInput; so single- or multi-linelabel (
str) – The label for this component, max 45 charactersmin_length (Optional[
int]) – The minimum input length for a text input, min 0, max 4000max_length (Optional[
int]) – The maximum input length for a text input, min 1, max 4000required (Optional[
bool] = True) – Whether this component is required to be filled, default Truevalue (Optional[
str]) – A pre-filled value for this component, max 4000 charactersplaceholder (Optional[
str]) – Custom placeholder text if the input is empty, max 100 characters
- property custom_id
Union[
str,int] (depending on whether it is completely numeric or not):A developer defined ID for this component. This must be unique per
Message/ModalMax. 100 characters long.Note
The custom ID is a good place to store any additional data. For example if you want to make a check in the callback whether the author is a specific user just store the user-id in the custom_id like
# The custom_id custom_id=f'some-prefix:{ctx.author.id}' # Now you can extract this information again in the callback by splitting it at the separator. _, author_id = custom_id.split(':') # Note that the author_id is still a string here, not an integer!
Of course, you can store any and as much data in it as you want. (As long as it does not exceed the max. length)