Rich Select Implementations¶
Default implementation of select-based components.
Classes¶
- asyncas_ui_component
- asynccallback
- clsget_factory
- clsget_manager
- asyncmake_custom_id
- clsset_factory
- clsset_manager
- class disnake_compass.impl.component.select.BaseSelect(*args, **kwargs)[source]¶
Bases:
RichSelect,ComponentBase,ProtocolThe base class of a disnake-compass select menu.
For implementations, see
RichStringSelect,RichUserSelect,RichRoleSelect,RichMentionableSelect,RichChannelSelect.Attributes¶
- disabled: bool¶
Whether or not this button is disabled.
A disabled select is greyed out on discord, and cannot be used. Disabled selects can therefore not cause any interactions, either.
- max_values: int¶
The maximum number of values the user may select.
This must lie between 1 and 25, inclusive.
- min_values: int¶
The minimum number of values the user must select.
This must lie between 1 and 25, inclusive.
Methods¶
- await as_ui_component(manager=None, /)[source]¶
Convert this component into a component that can be sent by disnake.
- Returns:
A component that can be sent by disnake, maintaining the parameters and custom id set on this rich component.
- Return type:
- abstractmethod await callback(inter, /)[source]¶
Run the component callback.
This should be implemented by the user in each concrete component type.
- Parameters:
interaction – The interaction that caused this button to fire.
- classmethod get_factory()[source]¶
Get the factory that built this component instance.
Note
Component base classes can be declared as a subclass of
Protocols, which tells disnake_compass that this component is a ‘template’ and should not be instantiable. In this case, this attribute defaults to aNoopFactory.In case a concrete component subclass is created, a matching
ComponentFactoryis automatically generated instead.
- classmethod get_manager()[source]¶
Get the manager that was responsible for parsing this component instance.
- await make_custom_id(manager, /)[source]¶
Make a custom id from this component given its current state.
The generated custom id will contain the full state of the component, such that it be used to entirely reconstruct the component later.
Because parameter to string conversion supports asynchronous callbacks, this has to be an async function instead of e.g. a property.
Note
As the logic for translating a component to and from a custom id resides inside the component manager, the component must be registered to a manager to use this method.
- Parameters:
manager (
ComponentManager|None) – The manager to use to make a custom id for this component. This is only relevant if you have multiple managers for the same component. Defaults to the root manager.- Returns:
The custom id representing the full state of this component.
- Return type:
- asyncas_ui_component
- asynccallback
- clsget_factory
- clsget_manager
- asyncmake_custom_id
- clsset_factory
- clsset_manager
- class disnake_compass.impl.component.select.RichStringSelect(*args, **kwargs)[source]¶
Bases:
BaseSelect,ProtocolThe default implementation of a disnake-compass string select.
This works similar to a dataclass, but with some extra things to take into account.
First and foremost, there are class variables for
placeholder,min_values,max_values,disabled, and:attr:options. These set the corresponding attributes on the select class when they are sent to discord, and are meant to be overwritten by the user.Fields can be defined similarly to dataclasses, by means of a name, a type annotation, and an optional
disnake_compass.field()to set the default or a custom parser. The options field specifically is designated withdisnake_compass.options()instead.Classes created in this way have auto-generated slots and an auto-generated
__init__. The init-signature contains all the custom id fields as keyword-only arguments.Attributes¶
- disabled: bool¶
Whether or not this button is disabled.
A disabled select is greyed out on discord, and cannot be used. Disabled selects can therefore not cause any interactions, either.
- max_values: int¶
The maximum number of values the user may select.
This must lie between 1 and 25, inclusive.
- min_values: int¶
The minimum number of values the user must select.
This must lie between 1 and 25, inclusive.
- options: list[disnake.SelectOption]¶
The options for this select menu.
Must be a list of between 1 and 25 strings.
Methods¶
- await as_ui_component(manager=None, /)[source]¶
Convert this component into a component that can be sent by disnake.
- Returns:
A component that can be sent by disnake, maintaining the parameters and custom id set on this rich component.
- Return type:
- abstractmethod await callback(inter, /)[source]¶
Run the component callback.
This should be implemented by the user in each concrete component type.
- Parameters:
interaction – The interaction that caused this button to fire.
- classmethod get_factory()[source]¶
Get the factory that built this component instance.
Note
Component base classes can be declared as a subclass of
Protocols, which tells disnake_compass that this component is a ‘template’ and should not be instantiable. In this case, this attribute defaults to aNoopFactory.In case a concrete component subclass is created, a matching
ComponentFactoryis automatically generated instead.
- classmethod get_manager()[source]¶
Get the manager that was responsible for parsing this component instance.
- await make_custom_id(manager, /)[source]¶
Make a custom id from this component given its current state.
The generated custom id will contain the full state of the component, such that it be used to entirely reconstruct the component later.
Because parameter to string conversion supports asynchronous callbacks, this has to be an async function instead of e.g. a property.
Note
As the logic for translating a component to and from a custom id resides inside the component manager, the component must be registered to a manager to use this method.
- Parameters:
manager (
ComponentManager|None) – The manager to use to make a custom id for this component. This is only relevant if you have multiple managers for the same component. Defaults to the root manager.- Returns:
The custom id representing the full state of this component.
- Return type:
- asyncas_ui_component
- asynccallback
- clsget_factory
- clsget_manager
- asyncmake_custom_id
- clsset_factory
- clsset_manager
- class disnake_compass.impl.component.select.RichUserSelect(*args, **kwargs)[source]¶
Bases:
BaseSelect,ProtocolThe default implementation of a disnake-compass user select.
This works similar to a dataclass, but with some extra things to take into account.
First and foremost, there are class variables for
placeholder,min_values,max_values,disabled. These set the corresponding attributes on the select class when they are sent to discord, and are meant to be overwritten by the user.Fields can be defined similarly to dataclasses, by means of a name, a type annotation, and an optional
disnake_compass.field()to set the default or a custom parser. The options field specifically is designated withdisnake_compass.options()instead.Classes created in this way have auto-generated slots and an auto-generated
__init__. The init-signature contains all the custom id fields as keyword-only arguments.Attributes¶
- disabled: bool¶
Whether or not this button is disabled.
A disabled select is greyed out on discord, and cannot be used. Disabled selects can therefore not cause any interactions, either.
- max_values: int¶
The maximum number of values the user may select.
This must lie between 1 and 25, inclusive.
- min_values: int¶
The minimum number of values the user must select.
This must lie between 1 and 25, inclusive.
Methods¶
- await as_ui_component(manager=None, /)[source]¶
Convert this component into a component that can be sent by disnake.
- Returns:
A component that can be sent by disnake, maintaining the parameters and custom id set on this rich component.
- Return type:
- abstractmethod await callback(inter, /)[source]¶
Run the component callback.
This should be implemented by the user in each concrete component type.
- Parameters:
interaction – The interaction that caused this button to fire.
- classmethod get_factory()[source]¶
Get the factory that built this component instance.
Note
Component base classes can be declared as a subclass of
Protocols, which tells disnake_compass that this component is a ‘template’ and should not be instantiable. In this case, this attribute defaults to aNoopFactory.In case a concrete component subclass is created, a matching
ComponentFactoryis automatically generated instead.
- classmethod get_manager()[source]¶
Get the manager that was responsible for parsing this component instance.
- await make_custom_id(manager, /)[source]¶
Make a custom id from this component given its current state.
The generated custom id will contain the full state of the component, such that it be used to entirely reconstruct the component later.
Because parameter to string conversion supports asynchronous callbacks, this has to be an async function instead of e.g. a property.
Note
As the logic for translating a component to and from a custom id resides inside the component manager, the component must be registered to a manager to use this method.
- Parameters:
manager (
ComponentManager|None) – The manager to use to make a custom id for this component. This is only relevant if you have multiple managers for the same component. Defaults to the root manager.- Returns:
The custom id representing the full state of this component.
- Return type:
- asyncas_ui_component
- asynccallback
- clsget_factory
- clsget_manager
- asyncmake_custom_id
- clsset_factory
- clsset_manager
- class disnake_compass.impl.component.select.RichRoleSelect(*args, **kwargs)[source]¶
Bases:
BaseSelect,ProtocolThe default implementation of a disnake-compass role select.
This works similar to a dataclass, but with some extra things to take into account.
First and foremost, there are class variables for
placeholder,min_values,max_values,disabled. These set the corresponding attributes on the select class when they are sent to discord, and are meant to be overwritten by the user.Fields can be defined similarly to dataclasses, by means of a name, a type annotation, and an optional
disnake_compass.field()to set the default or a custom parser. The options field specifically is designated withdisnake_compass.options()instead.Classes created in this way have auto-generated slots and an auto-generated
__init__. The init-signature contains all the custom id fields as keyword-only arguments.Attributes¶
- disabled: bool¶
Whether or not this button is disabled.
A disabled select is greyed out on discord, and cannot be used. Disabled selects can therefore not cause any interactions, either.
- max_values: int¶
The maximum number of values the user may select.
This must lie between 1 and 25, inclusive.
- min_values: int¶
The minimum number of values the user must select.
This must lie between 1 and 25, inclusive.
Methods¶
- await as_ui_component(manager=None, /)[source]¶
Convert this component into a component that can be sent by disnake.
- Returns:
A component that can be sent by disnake, maintaining the parameters and custom id set on this rich component.
- Return type:
- abstractmethod await callback(inter, /)[source]¶
Run the component callback.
This should be implemented by the user in each concrete component type.
- Parameters:
interaction – The interaction that caused this button to fire.
- classmethod get_factory()[source]¶
Get the factory that built this component instance.
Note
Component base classes can be declared as a subclass of
Protocols, which tells disnake_compass that this component is a ‘template’ and should not be instantiable. In this case, this attribute defaults to aNoopFactory.In case a concrete component subclass is created, a matching
ComponentFactoryis automatically generated instead.
- classmethod get_manager()[source]¶
Get the manager that was responsible for parsing this component instance.
- await make_custom_id(manager, /)[source]¶
Make a custom id from this component given its current state.
The generated custom id will contain the full state of the component, such that it be used to entirely reconstruct the component later.
Because parameter to string conversion supports asynchronous callbacks, this has to be an async function instead of e.g. a property.
Note
As the logic for translating a component to and from a custom id resides inside the component manager, the component must be registered to a manager to use this method.
- Parameters:
manager (
ComponentManager|None) – The manager to use to make a custom id for this component. This is only relevant if you have multiple managers for the same component. Defaults to the root manager.- Returns:
The custom id representing the full state of this component.
- Return type:
- asyncas_ui_component
- asynccallback
- clsget_factory
- clsget_manager
- asyncmake_custom_id
- clsset_factory
- clsset_manager
- class disnake_compass.impl.component.select.RichMentionableSelect(*args, **kwargs)[source]¶
Bases:
BaseSelect,ProtocolThe default implementation of a disnake-compass mentionable select.
This works similar to a dataclass, but with some extra things to take into account.
First and foremost, there are class variables for
placeholder,min_values,max_values,disabled. These set the corresponding attributes on the select class when they are sent to discord, and are meant to be overwritten by the user.Fields can be defined similarly to dataclasses, by means of a name, a type annotation, and an optional
disnake_compass.field()to set the default or a custom parser. The options field specifically is designated withdisnake_compass.options()instead.Classes created in this way have auto-generated slots and an auto-generated
__init__. The init-signature contains all the custom id fields as keyword-only arguments.Attributes¶
- disabled: bool¶
Whether or not this button is disabled.
A disabled select is greyed out on discord, and cannot be used. Disabled selects can therefore not cause any interactions, either.
- max_values: int¶
The maximum number of values the user may select.
This must lie between 1 and 25, inclusive.
- min_values: int¶
The minimum number of values the user must select.
This must lie between 1 and 25, inclusive.
Methods¶
- await as_ui_component(manager=None, /)[source]¶
Convert this component into a component that can be sent by disnake.
- Returns:
A component that can be sent by disnake, maintaining the parameters and custom id set on this rich component.
- Return type:
- abstractmethod await callback(inter, /)[source]¶
Run the component callback.
This should be implemented by the user in each concrete component type.
- Parameters:
interaction – The interaction that caused this button to fire.
- classmethod get_factory()[source]¶
Get the factory that built this component instance.
Note
Component base classes can be declared as a subclass of
Protocols, which tells disnake_compass that this component is a ‘template’ and should not be instantiable. In this case, this attribute defaults to aNoopFactory.In case a concrete component subclass is created, a matching
ComponentFactoryis automatically generated instead.
- classmethod get_manager()[source]¶
Get the manager that was responsible for parsing this component instance.
- await make_custom_id(manager, /)[source]¶
Make a custom id from this component given its current state.
The generated custom id will contain the full state of the component, such that it be used to entirely reconstruct the component later.
Because parameter to string conversion supports asynchronous callbacks, this has to be an async function instead of e.g. a property.
Note
As the logic for translating a component to and from a custom id resides inside the component manager, the component must be registered to a manager to use this method.
- Parameters:
manager (
ComponentManager|None) – The manager to use to make a custom id for this component. This is only relevant if you have multiple managers for the same component. Defaults to the root manager.- Returns:
The custom id representing the full state of this component.
- Return type:
- asyncas_ui_component
- asynccallback
- clsget_factory
- clsget_manager
- asyncmake_custom_id
- clsset_factory
- clsset_manager
- class disnake_compass.impl.component.select.RichChannelSelect(*args, **kwargs)[source]¶
Bases:
BaseSelect,ProtocolThe default implementation of a disnake-compass channel select.
This works similar to a dataclass, but with some extra things to take into account.
First and foremost, there are class variables for
channel_types,placeholder,min_values,max_values,disabled. These set the corresponding attributes on the select class when they are sent to discord, and are meant to be overwritten by the user.Fields can be defined similarly to dataclasses, by means of a name, a type annotation, and an optional
disnake_compass.field()to set the default or a custom parser. The options field specifically is designated withdisnake_compass.options()instead.Classes created in this way have auto-generated slots and an auto-generated
__init__. The init-signature contains all the custom id fields as keyword-only arguments.Attributes¶
- channel_types: list[disnake.ChannelType] | None¶
The channel types to allow for this select menu.
Defaults to
None, implying all channel types are allowed.
- disabled: bool¶
Whether or not this button is disabled.
A disabled select is greyed out on discord, and cannot be used. Disabled selects can therefore not cause any interactions, either.
- max_values: int¶
The maximum number of values the user may select.
This must lie between 1 and 25, inclusive.
- min_values: int¶
The minimum number of values the user must select.
This must lie between 1 and 25, inclusive.
Methods¶
- await as_ui_component(manager=None, /)[source]¶
Convert this component into a component that can be sent by disnake.
- Returns:
A component that can be sent by disnake, maintaining the parameters and custom id set on this rich component.
- Return type:
- abstractmethod await callback(inter, /)[source]¶
Run the component callback.
This should be implemented by the user in each concrete component type.
- Parameters:
interaction – The interaction that caused this button to fire.
- classmethod get_factory()[source]¶
Get the factory that built this component instance.
Note
Component base classes can be declared as a subclass of
Protocols, which tells disnake_compass that this component is a ‘template’ and should not be instantiable. In this case, this attribute defaults to aNoopFactory.In case a concrete component subclass is created, a matching
ComponentFactoryis automatically generated instead.
- classmethod get_manager()[source]¶
Get the manager that was responsible for parsing this component instance.
- await make_custom_id(manager, /)[source]¶
Make a custom id from this component given its current state.
The generated custom id will contain the full state of the component, such that it be used to entirely reconstruct the component later.
Because parameter to string conversion supports asynchronous callbacks, this has to be an async function instead of e.g. a property.
Note
As the logic for translating a component to and from a custom id resides inside the component manager, the component must be registered to a manager to use this method.
- Parameters:
manager (
ComponentManager|None) – The manager to use to make a custom id for this component. This is only relevant if you have multiple managers for the same component. Defaults to the root manager.- Returns:
The custom id representing the full state of this component.
- Return type: