ActionRow
- class discord.ActionRow
Bases:
Generic
[T
]Represents an ActionRow-Part for the components of a
Message
orModal
.- components
The components the
ActionRow
holds. 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
ActionRow
and returns itself.
- insert_component_at(index, component)
Inserts a component before a specified index to the
ActionRow
and returns itself.
- set_component_at(index, component)
Modifies a component to the
ActionRow
and 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
ActionRow
and 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
ActionRow
and returns itself.
- disable_all_components()
Disables all components in this
ActionRow
and returns itself.- Returns:
The updated instance
- Return type:
- disable_all_components_if(check, *args, **kwargs)
Disables all
components
in thisActionRow
if the passedcheck
returnsTrue
and returns itself.- Parameters:
check (Union[
bool
, Callable[[Any, …],bool
]]) – Could be anbool
or usually anyCallable
that returns abool
*args (Any) – Positional arguments that should be passed in to the
check
if it is aCallable
**kwargs (Any) – Keyword-only arguments that should be passed in to the
check
if it is aCallable
- Returns:
The updated instance
- Return type:
- disable_all_buttons()
Disables any
Button
in thisActionRow
and returns itself.- Returns:
The updated instance
- Return type:
- disable_all_buttons_if(check, *args, **kwargs)
Disables any
Button
in thisActionRow
if the passedcheck
returnsTrue
and returns itself.- Parameters:
check (Union[
bool
, Callable[[Any, …],bool
]]) – Could be anbool
or usually anyCallable
that returns abool
*args (Any) – Positional arguments that should be passed in to the
check
if it is aCallable
**kwargs (Any) – Keyword-only arguments that should be passed in to the
check
if it is aCallable
- Returns:
The updated instance
- Return type:
Disables all Select like objects in this
ActionRow
and returns itself.- Returns:
The updated instance
- Return type:
Disables all Select like objects in this
ActionRow
if the passedcheck
returnsTrue
and returns itself.- Parameters:
check (Union[
bool
, Callable[[Any, …],bool
]]) – Could be anbool
or usually anyCallable
that returns abool
*args (Any) – Positional arguments that should be passed in to the
check
if it is aCallable
**kwargs (Any) – Keyword-only arguments that should be passed in to the
check
if it is aCallable
- Returns:
The updated instance
- Return type:
SelectOption
- class discord.SelectOption
Bases:
object
A 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
,value
ordescription
is too long.
SelectDefaultValue
- class discord.SelectDefaultValue
Bases:
object
A default value for a
UserSelect
,RoleSelect
,MentionableSelect
orChannelSelect
Note
As all of those select types except
MentionableSelect
accept only one type of value, you can for those just use instances of the mentioned type or aint
/str
/discord.Object
and 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 thatid
represents. 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:
BaseSelect
Very similar to
SelectMenu
but you can select from a list ofMember
/User
Note
options
can’t be set for this type. But you can setdefault_values
to a list ofMember
/User
to set the default values.See also
- property default_values
A list of values to select by default, must be within the range of
min_values
andmax_values
- Type:
List[
SelectDefaultValue
]
- values
The members/users that were selected
Note
This only exists if the
UserSelect
is 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
/Modal
Max. 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
check
returnsTrue
and returns itself.- Parameters:
check (Union[
bool
, Callable[[Any, …],bool
]]) – Could be anbool
or usually anyCallable
that returns abool
*args (Any) – Positional arguments that should be passed in to the
check
if it is aCallable
**kwargs (Any) – Keyword-only arguments that should be passed in to the
check
if 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
True
it 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:
BaseSelect
Very similar to
SelectMenu
but you can select from a list ofRole
Note
options
can’t be set for this type. But you can setdefault_values
to a list ofRole
to set the default values.See also
- property default_values
A list of roles to select by default, must be within the range of
min_values
andmax_values
- Type:
List[
SelectDefaultValue
]
- values
The roles that were selected
Note
This only exists if the
RoleSelect
is 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
/Modal
Max. 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
check
returnsTrue
and returns itself.- Parameters:
check (Union[
bool
, Callable[[Any, …],bool
]]) – Could be anbool
or usually anyCallable
that returns abool
*args (Any) – Positional arguments that should be passed in to the
check
if it is aCallable
**kwargs (Any) – Keyword-only arguments that should be passed in to the
check
if 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
True
it 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:
BaseSelect
Very similar to
SelectMenu
but you can select from a list of bothMember
/User
andRole
Note
options
can’t be set for this type. But you can setdefault_values
to a list ofMember
/User
/Role
to set the default values.See also
- property default_values
A list of values to select by default, must be within the range of
min_values
andmax_values
- Type:
List[
SelectDefaultValue
]
- values
The members/users and roles that were selected
Note
This only exists if the
MentionableSelect
is 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
/Modal
Max. 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
check
returnsTrue
and returns itself.- Parameters:
check (Union[
bool
, Callable[[Any, …],bool
]]) – Could be anbool
or usually anyCallable
that returns abool
*args (Any) – Positional arguments that should be passed in to the
check
if it is aCallable
**kwargs (Any) – Keyword-only arguments that should be passed in to the
check
if 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
True
it 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:
BaseSelect
Very similar to
SelectMenu
but you can select from a list of channels.For this type there is an additional parameter
channel_types
wich can be a list ofChannelType
(or the type itself likeTextChannel
orStageChannel
) that specify from what channel types the user could choose.Note
options
can’t be set for this type. But you can setdefault_values
to 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
/Modal
Max. 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
check
returnsTrue
and returns itself.- Parameters:
check (Union[
bool
, Callable[[Any, …],bool
]]) – Could be anbool
or usually anyCallable
that returns abool
*args (Any) – Positional arguments that should be passed in to the
check
if it is aCallable
**kwargs (Any) – Keyword-only arguments that should be passed in to the
check
if 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
True
it 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_values
andmax_values
- values
The channels that were selected
Note
This only exists if the
ChannelSelect
is 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:
BaseComponent
Represents 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
/Modal
Max. 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)