Components Addon¶
addon
¶
logger = logging.getLogger('scurrypy')
module-attribute
¶
C = TypeVar('C', bound=ComponentContext)
module-attribute
¶
AddonHandler: TypeAlias = _AddonHandler[Any]
module-attribute
¶
AddonDecorator: TypeAlias = Callable[[AddonHandler], AddonHandler]
module-attribute
¶
ComponentsAddon
¶
Bases: Addon
flowchart TD
scurrypy.ext.components.addon.ComponentsAddon[ComponentsAddon]
scurrypy.bases.addon.Addon[Addon]
scurrypy.bases.addon.Addon --> scurrypy.ext.components.addon.ComponentsAddon
click scurrypy.ext.components.addon.ComponentsAddon href "" "scurrypy.ext.components.addon.ComponentsAddon"
click scurrypy.bases.addon.Addon href "" "scurrypy.bases.addon.Addon"
Addon that implements automatic registering and decorating component interactions.
Parameters:
-
client(Client) –the bot client object
bot = client
instance-attribute
¶
component_handlers: dict[str, AddonHandler] = {}
instance-attribute
¶
Mapping of component custom IDs to handler.
on_startup
¶
Sets up the addon with the client.
component
¶
Common function for registering components.
Parameters:
-
custom_id(str) –custom ID of component
-
handler(AddonHandler, default:None) –callback for component (if not a decorator)
button
¶
Register and route button interactions.
Parameters:
-
custom_id(str) –custom ID of button
Important
Must match the
custom_idset where the component was created. -
handler(AddonHandler, default:None) –callback for the command (if not a decorator)
select
¶
Register and route select menu interactions.
Parameters:
-
custom_id(str) –custom ID of select menu
Important
Must match the
custom_idset where the component was created. -
handler(AddonHandler, default:None) –callback for the command (if not a decorator)
modal
¶
Register and route modal interactions.
Parameters:
-
custom_id(str) –custom ID of modal
Important
Must match the
custom_idset where the component was created. -
handler(AddonHandler, default:None) –callback for the command (if not a decorator)
dispatch
async
¶
Dispatch a response to an INTERACTION_CREATE event
Raises:
-
DataModelTypeError–no component context
Parameters:
-
event(InteractionEvent) –interaction event object