Context¶
discord_http.context module¶
- class discord_http.context.Context(bot: Client, data: dict)[source]¶
Bases:
object
- property created_at: datetime¶
datetime Returns the time the interaction was created
- async edit_original_response(*, content: str | None = <MISSING>, embed: ~discord_http.embeds.Embed | None = <MISSING>, embeds: list[~discord_http.embeds.Embed] | None = <MISSING>, view: ~discord_http.view.View | None = <MISSING>, attachment: ~discord_http.file.File | None = <MISSING>, attachments: list[~discord_http.file.File] | None = <MISSING>, allowed_mentions: ~discord_http.mentions.AllowedMentions | None = <MISSING>) Message [source]¶
Message Edit the original response to the interaction
- property expires_at: datetime¶
datetime Returns the time the interaction expires
- async original_response() Message [source]¶
Message Returns the original response to the interaction
- property response: InteractionResponse¶
InteractionResponse Returns the response to the interaction
- class discord_http.context.InteractionResponse(parent: Context)[source]¶
Bases:
object
- defer(ephemeral: bool = False, thinking: bool = False, call_after: Callable | None = None) DeferResponse [source]¶
Defer the response to the interaction
- Parameters:
ephemeral (bool) – If the response should be ephemeral (show only to the user)
thinking (bool) – If the response should show the “thinking” status
call_after (Optional[Callable]) – A coroutine to run after the response is sent
- Returns:
The response to the interaction
- Return type:
DeferResponse
- Raises:
TypeError – If call_after is not a coroutine
- edit_message(*, content: str | None = <MISSING>, embed: ~discord_http.embeds.Embed | None = <MISSING>, embeds: list[~discord_http.embeds.Embed] | None = <MISSING>, view: ~discord_http.view.View | None = <MISSING>, attachment: ~discord_http.file.File | None = <MISSING>, attachments: list[~discord_http.file.File] | None = <MISSING>, allowed_mentions: ~discord_http.mentions.AllowedMentions | None = <MISSING>, call_after: ~typing.Callable | None = None) MessageResponse [source]¶
Edit the original message of the interaction
- Parameters:
content (Optional[str]) – Content of the message
embed (Optional[Embed]) – Embed to edit the message with
embeds (Optional[list[Embed]]) – Multiple embeds to edit the message with
view (Optional[View]) – Components to include in the message
attachment (Optional[File]) – New file to edit the message with
attachments (Optional[Union[list[File], File]]) – Multiple new files to edit the message with
allowed_mentions (Optional[AllowedMentions]) – Allowed mentions for the message
call_after (Optional[Callable]) – A coroutine to run after the response is sent
- Returns:
The response to the interaction
- Return type:
MessageResponse
- Raises:
ValueError –
If both embed and embeds are passed - If both attachment and attachments are passed
TypeError – If call_after is not a coroutine
- send_autocomplete(choices: dict[Any, str]) AutocompleteResponse [source]¶
Send an autocomplete response to the interaction
- Parameters:
choices (dict[Union[str, int, float], str]) – The choices to send
- Returns:
The response to the interaction
- Return type:
AutocompleteResponse
- Raises:
TypeError –
If choices is not a dict - If choices is not a dict[Union[str, int, float], str]
- send_message(content: str | None = <MISSING>, *, embed: ~discord_http.embeds.Embed | None = <MISSING>, embeds: list[~discord_http.embeds.Embed] | None = <MISSING>, file: ~discord_http.file.File | None = <MISSING>, files: list[~discord_http.file.File] | None = <MISSING>, ephemeral: bool | None = False, view: ~discord_http.view.View | None = <MISSING>, tts: bool | None = False, type: ~discord_http.enums.ResponseType | int = 4, allowed_mentions: ~discord_http.mentions.AllowedMentions | None = <MISSING>, poll: ~discord_http.message.Poll | None = <MISSING>, call_after: ~typing.Callable | None = None) MessageResponse [source]¶
Send a message to the interaction
- Parameters:
content (Optional[str]) – Content of the message
embed (Optional[Embed]) – The embed to send
embeds (Optional[list[Embed]]) – Multiple embeds to send
file (Optional[File]) – A file to send
files (Optional[Union[list[File], File]]) – Multiple files to send
ephemeral (bool) – If the message should be ephemeral (show only to the user)
view (Optional[View]) – Components to include in the message
tts (bool) – Whether the message should be sent using text-to-speech
type (Optional[ResponseType]) – The type of response to send
allowed_mentions (Optional[AllowedMentions]) – Allowed mentions for the message
call_after (Optional[Callable]) – A coroutine to run after the response is sent
- Returns:
The response to the interaction
- Return type:
MessageResponse
- Raises:
ValueError –
If both embed and embeds are passed - If both file and files are passed
TypeError – If call_after is not a coroutine
- send_modal(modal: Modal, *, call_after: Callable | None = None) ModalResponse [source]¶
Send a modal to the interaction
- Parameters:
modal (Modal) – The modal to send
call_after (Optional[Callable]) – A coroutine to run after the response is sent
- Returns:
The response to the interaction
- Return type:
ModalResponse
- Raises:
TypeError –
If modal is not a Modal instance - If call_after is not a coroutine