lightbulb.context¶
- class lightbulb.context.AutocompleteContext(client: 'client_.Client', interaction: 'hikari.AutocompleteInteraction', options: 't.Sequence[hikari.AutocompleteInteractionOption]', command: 'type[commands.CommandBase]')[source]¶
- get_option(name: str) AutocompleteInteractionOption | None [source]¶
Get the option with the given name if available.
- Parameters:
name (
str
) – The name of the option to get.- Returns:
- The
option, or
None
if not available from the interaction.
- Return type:
Optional
[hikari.interactions.command_interactions.AutocompleteInteractionOption
]
See also
- async respond(choices: Sequence[AutocompleteChoiceBuilder] | Sequence[str] | Mapping[str, str] | Sequence[tuple[str, str]] | Sequence[int] | Mapping[str, int] | Sequence[tuple[str, int]] | Sequence[float] | Mapping[str, float] | Sequence[tuple[str, float]]) None [source]¶
Create a response for the autocomplete interaction this context represents.
- Parameters:
choices – The choices to respond to the interaction with.
- Returns:
- client: client_.Client¶
The client that created the context.
- command: type[commands.CommandBase]¶
Command class for the autocomplete invocation.
- property focused: AutocompleteInteractionOption¶
The focused option for the autocomplete interaction - the option currently being autocompleted.
See also
- interaction: hikari.AutocompleteInteraction¶
The interaction for the autocomplete invocation.
- options: t.Sequence[hikari.AutocompleteInteractionOption]¶
The options provided with the autocomplete interaction.
- class lightbulb.context.Context(client: client_.Client, interaction: hikari.CommandInteraction, options: t.Sequence[hikari.CommandInteractionOption], command: commands.CommandBase)[source]¶
Dataclass representing the context for a single command invocation.
- async defer(ephemeral: bool = False) None [source]¶
Defer the creation of a response for the interaction that this context represents.
- async delete_response(response_id: Snowflake | int) None [source]¶
Delete the response with the given identifier.
- Parameters:
response_id (
hikari.snowflakes.Snowflakeish
) – The identifier of the response to delete - as returned byrespond()
.- Returns:
- async edit_response(response_id: hikari.Snowflakeish, content: hikari.UndefinedNoneOr[t.Any] = UNDEFINED, *, attachment: hikari.UndefinedNoneOr[hikari.Resourceish | hikari.Attachment] = UNDEFINED, attachments: hikari.UndefinedNoneOr[t.Sequence[hikari.Resourceish | hikari.Attachment]] = UNDEFINED, component: hikari.UndefinedNoneOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedNoneOr[t.Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedNoneOr[hikari.Embed] = UNDEFINED, embeds: hikari.UndefinedNoneOr[t.Sequence[hikari.Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[hikari.PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[hikari.PartialRole] | bool] = UNDEFINED) hikari.Message [source]¶
Edit the response with the given identifier.
- Parameters:
response_id (
hikari.snowflakes.Snowflakeish
) – The identifier of the response to delete - as returned byrespond()
.content – The message contents.
attachment – The message attachment.
attachments – The message attachments.
component – The builder object of the component to include in this message.
components – The sequence of the component builder objects to include in this message.
embed – The message embed.
embeds – The message embeds.
mentions_everyone – Whether the message should parse @everyone/@here mentions.
user_mentions – The user mentions to include in the message.
role_mentions – The role mentions to include in the message.
- Returns:
The updated message object for the response with the given identifier.
- Return type:
Note
This documentation does not contain a full description of the parameters as they would just be copy-pasted from the hikari documentation. See
edit_initial_response
for a more detailed description.
- async fetch_response(response_id: Snowflake | int) Message [source]¶
Fetch the message object for the response with the given identifier.
- Parameters:
response_id (
Snowflakeish
) – The identifier of the response to fetch - as returned byrespond()
.- Returns:
The message for the response with the given identifier.
- Return type:
- async respond(content: hikari.UndefinedOr[t.Any] = UNDEFINED, *, flags: int | hikari.MessageFlag | hikari.UndefinedType = UNDEFINED, tts: hikari.UndefinedOr[bool] = UNDEFINED, attachment: hikari.UndefinedOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedOr[t.Sequence[hikari.Resourceish]] = UNDEFINED, component: hikari.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedOr[t.Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedOr[hikari.Embed] = UNDEFINED, embeds: hikari.UndefinedOr[t.Sequence[hikari.Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[hikari.PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[hikari.PartialRole] | bool] = UNDEFINED) hikari.Snowflakeish [source]¶
Create a response to the interaction that this context represents.
- Parameters:
content – The message contents.
attachment – The message attachment.
attachments – The message attachments.
component – The builder object of the component to include in this message.
components – The sequence of the component builder objects to include in this message.
embed – The message embed.
embeds – The message embeds.
flags – The message flags this response should have.
tts – Whether the message will be read out by a screen reader using Discord’s TTS (text-to-speech) system.
mentions_everyone – Whether the message should parse @everyone/@here mentions.
user_mentions – The user mentions to include in the message.
role_mentions – The role mentions to include in the message.
- Returns:
- An identifier for the response. This can then be used to edit, delete, or
fetch the response message using the appropriate methods.
- Return type:
Note
This documentation does not contain a full description of the parameters as they would just be copy-pasted from the hikari documentation. See
create_initial_response
for a more detailed description.
- async respond_with_modal(title: str, custom_id: str, component: ComponentBuilder | UndefinedType = UNDEFINED, components: Sequence[ComponentBuilder] | UndefinedType = UNDEFINED) None [source]¶
Create a modal response to the interaction that this context represents.
- Parameters:
title (
str
) – The title that will show up in the modal.custom_id (
str
) – Developer set custom ID used for identifying interactions with this modal.component (
UndefinedOr
[ComponentBuilder
]) – A component builder to send in this modal.components (
UndefinedOr
[Sequence
[ComponentBuilder
]]) – A sequence of component builders to send in this modal.
- Returns:
- client: client_.Client¶
The client that created the context.
- command: commands.CommandBase¶
Command instance for the command invocation.
- property command_data: commands.CommandData¶
The metadata for the invoked command.
- property guild_id: Snowflake | None¶
The ID of the guild that the command was invoked in.
None
if the invocation occurred in DM.
- interaction: hikari.CommandInteraction¶
The interaction for the command invocation.
- property member: InteractionMember | None¶
The member that invoked the command, if it was invoked in a guild.
- options: t.Sequence[hikari.CommandInteractionOption]¶
The options to use for the command invocation.
- class lightbulb.context.RestContext(client: 'client_.Client', interaction: 'hikari.CommandInteraction', options: 't.Sequence[hikari.CommandInteractionOption]', command: 'commands.CommandBase', _initial_response_callback: 't.Callable[[hikari.api.InteractionResponseBuilder], None]')[source]¶
- async respond_with_modal(title: str, custom_id: str, component: ComponentBuilder | UndefinedType = UNDEFINED, components: Sequence[ComponentBuilder] | UndefinedType = UNDEFINED) None [source]¶
Create a modal response to the interaction that this context represents.
- Parameters:
title (
str
) – The title that will show up in the modal.custom_id (
str
) – Developer set custom ID used for identifying interactions with this modal.component (
UndefinedOr
[ComponentBuilder
]) – A component builder to send in this modal.components (
UndefinedOr
[Sequence
[ComponentBuilder
]]) – A sequence of component builders to send in this modal.
- Returns: