lightbulb.context¶
- class AutocompleteContext(client: client_.Client, interaction: AutocompleteInteraction, options: Sequence[AutocompleteInteractionOption], command: type[CommandBase])[source]¶
Class representing the context for an autocomplete interaction.
- get_option(name: str) AutocompleteInteractionOption | None [source]¶
Get the option with the given name if available. If the option has localization enabled, you should use its localization key.
- Parameters:
name – The name of the option to get.
- Returns:
The option, or
None
if not available from the interaction.
See also
- async respond(choices: Sequence[AutocompleteChoiceBuilder] | Sequence[T] | Mapping[str, T] | Sequence[tuple[str, T]]) 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[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: AutocompleteInteraction¶
The interaction for the autocomplete invocation.
- options: Sequence[AutocompleteInteractionOption]¶
The options provided with the autocomplete interaction.
- class Context(client: client_.Client, interaction: CommandInteraction, options: Sequence[CommandInteractionOption], command: CommandBase)[source]¶
Class representing the context for a single command invocation.
- async defer(*, ephemeral: bool = False) None ¶
Defer the creation of a response for the interaction that this context represents.
- Parameters:
ephemeral – Whether to defer ephemerally (message only visible to the user that triggered the command).
- Returns:
- async delete_response(response_id: Snowflake | int) None ¶
Delete the response with the given identifier.
- async edit_response(response_id: hikari.Snowflakeish, content: hikari.UndefinedNoneOr[t.Any] = UNDEFINED, *, attachment: hikari.UndefinedNoneOr[hikari.Resourceish | Attachment] = UNDEFINED, attachments: hikari.UndefinedNoneOr[Sequence[hikari.Resourceish | Attachment]] = UNDEFINED, component: hikari.UndefinedNoneOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedNoneOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedNoneOr[Embed] = UNDEFINED, embeds: hikari.UndefinedNoneOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) Message ¶
Edit the response with the given identifier.
- Parameters:
response_id – The identifier of the response to delete - as returned by
respond()
.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 ¶
Fetch the message object for the response with the given identifier.
- async respond(content: hikari.UndefinedOr[t.Any] = UNDEFINED, *, ephemeral: bool = False, flags: int | MessageFlag | UndefinedType = UNDEFINED, tts: hikari.UndefinedOr[bool] = UNDEFINED, attachment: hikari.UndefinedOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedOr[Sequence[hikari.Resourceish]] = UNDEFINED, component: hikari.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedOr[Embed] = UNDEFINED, embeds: hikari.UndefinedOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) hikari.Snowflakeish ¶
Create a response to the interaction that this context represents.
- Parameters:
content – The message contents.
ephemeral – Whether the message should be ephemeral (only visible to the user that triggered the command). This is just a convenience argument - passing
flags=hikari.MessageFlag.EPHEMERAL
will function the same way.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 – The title that will show up in the modal.
custom_id – Developer set custom ID used for identifying interactions with this modal.
component – A component builder to send in this modal.
components – A sequence of component builders to send in this modal.
- Returns:
- Raises:
RuntimeError – If an initial response has already been sent.
- client: client_.Client¶
The client that created the context.
- command: CommandBase¶
Command instance for the command invocation.
- property command_data: 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.
- property interaction: 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: Sequence[CommandInteractionOption]¶
The options to use for the command invocation.
- class MessageResponseMixin[source]¶
Abstract mixin for contexts that allow creating responses to interactions.
- async defer(*, ephemeral: bool = False) None [source]¶
Defer the creation of a response for the interaction that this context represents.
- Parameters:
ephemeral – Whether to defer ephemerally (message only visible to the user that triggered the command).
- Returns:
- async delete_response(response_id: Snowflake | int) None [source]¶
Delete the response with the given identifier.
- async edit_response(response_id: hikari.Snowflakeish, content: hikari.UndefinedNoneOr[t.Any] = UNDEFINED, *, attachment: hikari.UndefinedNoneOr[hikari.Resourceish | Attachment] = UNDEFINED, attachments: hikari.UndefinedNoneOr[Sequence[hikari.Resourceish | Attachment]] = UNDEFINED, component: hikari.UndefinedNoneOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedNoneOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedNoneOr[Embed] = UNDEFINED, embeds: hikari.UndefinedNoneOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) Message [source]¶
Edit the response with the given identifier.
- Parameters:
response_id – The identifier of the response to delete - as returned by
respond()
.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.
- async respond(content: hikari.UndefinedOr[t.Any] = UNDEFINED, *, ephemeral: bool = False, flags: int | MessageFlag | UndefinedType = UNDEFINED, tts: hikari.UndefinedOr[bool] = UNDEFINED, attachment: hikari.UndefinedOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedOr[Sequence[hikari.Resourceish]] = UNDEFINED, component: hikari.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedOr[Embed] = UNDEFINED, embeds: hikari.UndefinedOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) hikari.Snowflakeish [source]¶
Create a response to the interaction that this context represents.
- Parameters:
content – The message contents.
ephemeral – Whether the message should be ephemeral (only visible to the user that triggered the command). This is just a convenience argument - passing
flags=hikari.MessageFlag.EPHEMERAL
will function the same way.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.
- abstract property interaction: RespondableInteractionT¶
The interaction that this context is for.
- class RestContext(*args: Any, _initial_response_callback: Callable[[InteractionResponseBuilder], None], **kwargs: Any)[source]¶
- async defer(*, ephemeral: bool = False) None ¶
Defer the creation of a response for the interaction that this context represents.
- Parameters:
ephemeral – Whether to defer ephemerally (message only visible to the user that triggered the command).
- Returns:
- async delete_response(response_id: Snowflake | int) None ¶
Delete the response with the given identifier.
- async edit_response(response_id: hikari.Snowflakeish, content: hikari.UndefinedNoneOr[t.Any] = UNDEFINED, *, attachment: hikari.UndefinedNoneOr[hikari.Resourceish | Attachment] = UNDEFINED, attachments: hikari.UndefinedNoneOr[Sequence[hikari.Resourceish | Attachment]] = UNDEFINED, component: hikari.UndefinedNoneOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedNoneOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedNoneOr[Embed] = UNDEFINED, embeds: hikari.UndefinedNoneOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) Message ¶
Edit the response with the given identifier.
- Parameters:
response_id – The identifier of the response to delete - as returned by
respond()
.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 ¶
Fetch the message object for the response with the given identifier.
- async respond(content: hikari.UndefinedOr[t.Any] = UNDEFINED, *, ephemeral: bool = False, flags: int | MessageFlag | UndefinedType = UNDEFINED, tts: hikari.UndefinedOr[bool] = UNDEFINED, attachment: hikari.UndefinedOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedOr[Sequence[hikari.Resourceish]] = UNDEFINED, component: hikari.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedOr[Embed] = UNDEFINED, embeds: hikari.UndefinedOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) hikari.Snowflakeish ¶
Create a response to the interaction that this context represents.
- Parameters:
content – The message contents.
ephemeral – Whether the message should be ephemeral (only visible to the user that triggered the command). This is just a convenience argument - passing
flags=hikari.MessageFlag.EPHEMERAL
will function the same way.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 – The title that will show up in the modal.
custom_id – Developer set custom ID used for identifying interactions with this modal.
component – A component builder to send in this modal.
components – A sequence of component builders to send in this modal.
- Returns:
- Raises:
RuntimeError – If an initial response has already been sent.
- client: client_.Client¶
The client that created the context.
- command: CommandBase¶
Command instance for the command invocation.
- property command_data: 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.
- property interaction: 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: Sequence[CommandInteractionOption]¶
The options to use for the command invocation.