Context API Reference#
- class flare.context.message.MessageContext(interaction: T)[source]#
Bases:
PartialContext
[ComponentInteraction
]- async get_components() MutableSequence[Row] [source]#
Returns the flare components for the interaction this context is proxying
- property channels: Sequence[PartialChannel]#
The values selected for a channel select menu.
- class flare.context.modal.ModalContext(interaction: T)[source]#
Bases:
PartialContext
[ModalInteraction
]- property components: Sequence[ActionRowComponent[TextInputComponent]]#
Returns the components for this modal.
- class flare.context.base.InteractionResponse(context: PartialContext[Any], message: Message | None = None)[source]#
Bases:
object
Represents a response to an interaction, allows for standardized handling of responses. This class is not meant to be directly instantiated, and is instead returned by flare.context.PartialContext.
- async edit(content: hikari.UndefinedOr[t.Any] = UNDEFINED, *, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedOr[t.Sequence[hikari.api.ComponentBuilder]] = UNDEFINED, attachment: hikari.UndefinedNoneOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedNoneOr[t.Sequence[hikari.Resourceish]] = 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[t.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool]] = UNDEFINED, role_mentions: hikari.UndefinedOr[t.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool]] = UNDEFINED) InteractionResponse [source]#
A short-hand method to edit the message belonging to this response.
- Parameters:
content – The content of the message. Anything passed here will be cast to str.
attachment – An attachment to add to this message.
attachments – A sequence of attachments to add to this message.
component – A component to add to this message.
components – A sequence of components to add to this message.
embed – An embed to add to this message.
embeds – A sequence of embeds to add to this message.
mentions_everyone – If True, mentioning @everyone will be allowed.
user_mentions – The set of allowed user mentions in this message. Set to True to allow all.
role_mentions – The set of allowed role mentions in this message. Set to True to allow all.
- Returns:
A proxy object representing the response to the interaction.
- Return type:
- async retrieve_message() Message [source]#
Get or fetch the message created by this response. Initial responses need to be fetched, while followups will be provided directly.
- > ℹ️
The object itself can also be awaited directly, which in turn calls this method, producing the same results.
- Returns:
The message created by this response.
- Return type:
hikari.Message
- class flare.context.base.PartialContext(interaction: T)[source]#
Bases:
Generic
[T
]A context object proxying a Discord interaction.
- async defer(response_type: ~typing.Literal[<ResponseType.DEFERRED_MESSAGE_CREATE: 5>, <ResponseType.DEFERRED_MESSAGE_UPDATE: 6>] = <ResponseType.DEFERRED_MESSAGE_CREATE: 5>, *, flags: int | ~hikari.messages.MessageFlag | ~hikari.undefined.UndefinedType = UNDEFINED) None [source]#
Short-hand method to defer an interaction response. Raises RuntimeError if the interaction was already responded to.
- Parameters:
response_type (t.Literal[hikari.ResponseType.DEFERRED_MESSAGE_CREATE, hikari.ResponseType.DEFERRED_MESSAGE_UPDATE], optional) – The response-type of this defer action. Defaults to DEFERRED_MESSAGE_UPDATE.
flags (t.Union[int, hikari.MessageFlag, None], optional) – Message flags that should be included with this defer request, by default None
- Raises:
RuntimeError – The interaction was already responded to.
ValueError – response_type was not a deferred response type.
- async edit_response(content: hikari.UndefinedNoneOr[t.Any] = UNDEFINED, *, flags: t.Union[int, hikari.MessageFlag, hikari.UndefinedType] = UNDEFINED, tts: hikari.UndefinedOr[bool] = UNDEFINED, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedOr[t.Sequence[hikari.api.ComponentBuilder]] = UNDEFINED, attachment: hikari.UndefinedNoneOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedNoneOr[t.Sequence[hikari.Resourceish]] = 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[t.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool]] = UNDEFINED, role_mentions: hikari.UndefinedOr[t.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool]] = UNDEFINED) InteractionResponse [source]#
A short-hand method to edit the last message belonging to this interaction. In the case of modals, this will be the component’s message that triggered the modal.
- Parameters:
content – The content of the message. Anything passed here will be cast to str.
tts – If the message should be tts or not.
attachment – An attachment to add to this message.
attachments – A sequence of attachments to add to this message.
component – A component to add to this message.
components – A sequence of components to add to this message.
embed – An embed to add to this message.
embeds – A sequence of embeds to add to this message.
mentions_everyone – If True, mentioning @everyone will be allowed.
user_mentions – The set of allowed user mentions in this message. Set to True to allow all.
role_mentions – The set of allowed role mentions in this message. Set to True to allow all.
flags – Message flags that should be included with this message.
- Returns:
A proxy object representing the response to the interaction.
- Return type:
- get_channel() TextableGuildChannel | None [source]#
Gets the channel this context represents, None if in a DM. Requires application cache.
- get_guild() GatewayGuild | None [source]#
Gets the guild this context represents, if any. Requires application cache.
- async get_last_response() InteractionResponse [source]#
Get the last response issued to the interaction this context is proxying.
- Returns:
The response object.
- Return type:
- Raises:
RuntimeError – The interaction was not yet responded to.
- async respond(content: hikari.UndefinedOr[t.Any] = UNDEFINED, *, flags: t.Union[int, hikari.MessageFlag, hikari.UndefinedType] = UNDEFINED, tts: hikari.UndefinedOr[bool] = UNDEFINED, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedOr[t.Sequence[hikari.api.ComponentBuilder]] = UNDEFINED, attachment: hikari.UndefinedOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedOr[t.Sequence[hikari.Resourceish]] = 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[t.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool]] = UNDEFINED, role_mentions: hikari.UndefinedOr[t.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool]] = UNDEFINED) InteractionResponse [source]#
Short-hand method to create a new message response via the interaction this context represents.
- Parameters:
content – The content of the message. Anything passed here will be cast to str.
tts – If the message should be tts or not.
attachment – An attachment to add to this message.
attachments – A sequence of attachments to add to this message.
component – A component to add to this message.
components – A sequence of components to add to this message.
embed – An embed to add to this message.
embeds – A sequence of embeds to add to this message.
mentions_everyone – If True, mentioning @everyone will be allowed.
user_mentions – The set of allowed user mentions in this message. Set to True to allow all.
role_mentions – The set of allowed role mentions in this message. Set to True to allow all.
flags – Message flags that should be included with this message.
- Returns:
A proxy object representing the response to the interaction.
- Return type:
- property app_permissions: Permissions | None#
The permissions of the user who triggered the interaction. Will be None in DMs.
- property custom_id: str#
The developer provided unique identifier for the interaction this context is proxying.
- property guild_id: Snowflake | None#
The ID of the guild the context represents. Will be None in DMs.
- property guild_locale: str | Locale | None#
The guild locale of this context, if in a guild. This will default to en-US if not a community guild.
- property interaction: T#
The underlying interaction object.
- property member: InteractionMember | None#
The member who triggered this interaction. Will be None in DMs.
- property responses: Sequence[InteractionResponse]#
A list of all responses issued to the interaction this context is proxying.