Contextos de interação¶
Respondendo a interações explica como eles são usados.
bostie.Context
¶
Context(interaction: I, bot: Bot, *, received: float, ephemeral: bool, allowed_mentions: AllowedMentions, deletions: set[Task[None]])
Bases: _ReplyingContext[CommandInteraction, WebhookMessage]
The context of a command run: who ran it, where, and how to answer.
voice
property
¶
voice: ContextVoice
Voice in this guild; connect() joins the channel of the user who ran it.
command_name
property
¶
command_name: str
The invoked command with its subcommands, such as "role color set".
typing
¶
typing() -> Typing
Typing in the interaction's channel, awaited once or kept in async with.
respond
async
¶
respond(content: str | None = None, *, delete_after: float | None = None, **parts: Unpack[ReplyParts]) -> WebhookMessage
Answer, fill in the deferred answer, or send a follow-up, whichever fits.
delete_after deletes that message so many seconds later, within 15 minutes.
defer
async
¶
defer(*, ephemeral: bool | None = None) -> None
Show "thinking…" and answer later with respond.
edit
async
¶
edit(**parts: Unpack[ReplyEditParts]) -> M
edit(message_id: int, /, **parts: Unpack[ReplyEditParts]) -> WebhookMessage
edit(message_id: int | None = None, /, **parts: Unpack[ReplyEditParts]) -> M | WebhookMessage
Edit the original answer, or the follow-up message_id.
A part not given stays and None clears it. With files or attachments,
only the listed attachments stay.
fetch
async
¶
fetch() -> M
fetch(message_id: int) -> WebhookMessage
fetch(message_id: int | None = None) -> M | WebhookMessage
The original answer as Discord has it now, or the follow-up message_id.
followup
async
¶
followup(content: str | None = None, *, delete_after: float | None = None, **parts: Unpack[ReplyParts]) -> WebhookMessage
Send another message, or fill in the answer right after defer().
delete
async
¶
delete(message_id: int | None = None) -> None
Delete the original answer, or the follow-up message_id.
bostie.ComponentContext
¶
ComponentContext(interaction: I, bot: Bot, *, received: float, ephemeral: bool, allowed_mentions: AllowedMentions, deletions: set[Task[None]])
Bases: _UpdatingContext[ComponentInteraction]
The context of a button or select menu use.
voice
property
¶
voice: ContextVoice
Voice in this guild; connect() joins the channel of the user who ran it.
members
property
¶
members: tuple[ResolvedMember, ...]
The members picked in a user or mentionable select in a guild.
typing
¶
typing() -> Typing
Typing in the interaction's channel, awaited once or kept in async with.
respond
async
¶
respond(content: str | None = None, *, delete_after: float | None = None, **parts: Unpack[ReplyParts]) -> WebhookMessage
Answer, fill in the deferred answer, or send a follow-up, whichever fits.
delete_after deletes that message so many seconds later, within 15 minutes.
defer
async
¶
defer(*, ephemeral: bool | None = None) -> None
Show "thinking…" and answer later with respond.
edit
async
¶
edit(**parts: Unpack[ReplyEditParts]) -> M
edit(message_id: int, /, **parts: Unpack[ReplyEditParts]) -> WebhookMessage
edit(message_id: int | None = None, /, **parts: Unpack[ReplyEditParts]) -> M | WebhookMessage
Edit the original answer, or the follow-up message_id.
A part not given stays and None clears it. With files or attachments,
only the listed attachments stay.
fetch
async
¶
fetch() -> M
fetch(message_id: int) -> WebhookMessage
fetch(message_id: int | None = None) -> M | WebhookMessage
The original answer as Discord has it now, or the follow-up message_id.
followup
async
¶
followup(content: str | None = None, *, delete_after: float | None = None, **parts: Unpack[ReplyParts]) -> WebhookMessage
Send another message, or fill in the answer right after defer().
delete
async
¶
delete(message_id: int | None = None) -> None
Delete the original answer, or the follow-up message_id.
launch_activity
async
¶
launch_activity() -> str
Open the app's Activity for the user; return the id of its instance.
defer_update
async
¶
defer_update() -> None
Acknowledge silently; edit the component's message later with update.
update
async
¶
update(**parts: Unpack[ReplyEditParts]) -> Message | WebhookMessage
Edit the component's message: a part not given stays and None clears it.
With files or attachments, only the listed attachments stay.
bostie.ModalContext
¶
ModalContext(interaction: I, bot: Bot, *, received: float, ephemeral: bool, allowed_mentions: AllowedMentions, deletions: set[Task[None]])
Bases: _UpdatingContext[ModalSubmitInteraction]
The context of a modal submit; update edits the message that opened it.
voice
property
¶
voice: ContextVoice
Voice in this guild; connect() joins the channel of the user who ran it.
typing
¶
typing() -> Typing
Typing in the interaction's channel, awaited once or kept in async with.
respond
async
¶
respond(content: str | None = None, *, delete_after: float | None = None, **parts: Unpack[ReplyParts]) -> WebhookMessage
Answer, fill in the deferred answer, or send a follow-up, whichever fits.
delete_after deletes that message so many seconds later, within 15 minutes.
defer
async
¶
defer(*, ephemeral: bool | None = None) -> None
Show "thinking…" and answer later with respond.
edit
async
¶
edit(**parts: Unpack[ReplyEditParts]) -> M
edit(message_id: int, /, **parts: Unpack[ReplyEditParts]) -> WebhookMessage
edit(message_id: int | None = None, /, **parts: Unpack[ReplyEditParts]) -> M | WebhookMessage
Edit the original answer, or the follow-up message_id.
A part not given stays and None clears it. With files or attachments,
only the listed attachments stay.
fetch
async
¶
fetch() -> M
fetch(message_id: int) -> WebhookMessage
fetch(message_id: int | None = None) -> M | WebhookMessage
The original answer as Discord has it now, or the follow-up message_id.
followup
async
¶
followup(content: str | None = None, *, delete_after: float | None = None, **parts: Unpack[ReplyParts]) -> WebhookMessage
Send another message, or fill in the answer right after defer().
delete
async
¶
delete(message_id: int | None = None) -> None
Delete the original answer, or the follow-up message_id.
launch_activity
async
¶
launch_activity() -> str
Open the app's Activity for the user; return the id of its instance.
defer_update
async
¶
defer_update() -> None
Acknowledge silently; edit the component's message later with update.
update
async
¶
update(**parts: Unpack[ReplyEditParts]) -> Message | WebhookMessage
Edit the component's message: a part not given stays and None clears it.
With files or attachments, only the listed attachments stay.
values
¶
The options picked in the string select or checkbox group custom_id.
ids
¶
The ids of the users, roles, channels or files picked in custom_id.
users
¶
The users picked in the user or mentionable select custom_id.
members
¶
members(custom_id: str) -> tuple[ResolvedMember, ...]
The members picked in the user or mentionable select custom_id.
roles
¶
The roles picked in the role or mentionable select custom_id.
channels
¶
channels(custom_id: str) -> tuple[PartialChannel, ...]
The channels picked in the channel select custom_id.
attachments
¶
attachments(custom_id: str) -> tuple[Attachment, ...]
The files uploaded with the file upload custom_id.
choice
¶
The option picked in the radio group custom_id, if any.
bostie.AutocompleteContext
¶
Bases: _InteractionContext[AutocompleteInteraction]
The context of an autocomplete request; it never defers.
voice
property
¶
voice: ContextVoice
Voice in this guild; connect() joins the channel of the user who ran it.
options
property
¶
The options filled so far by name, as the handler gets them if they convert.
Required ones may be missing, and the focused one is the text typed so far.