Context¶
discord_http.context module¶
- class discord_http.context.Context(bot, data)¶
Bases:
object
- property channel: BaseChannel | PartialChannel | None¶
Returns the channel the interaction was made in.
- property channel_type: ChannelType¶
Returns the type of the channel.
- async create_followup_response(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, ephemeral=False, view=<MISSING>, tts=False, type=4, allowed_mentions=<MISSING>, poll=<MISSING>, flags=<MISSING>, delete_after=None) WebhookMessage ¶
Creates a new followup response to the interaction.
Do not use this to create a followup response when defer was called before. Use edit_original_response instead.
- Parameters:
ephemeral (
bool
|None
) – Whether the message should be sent as ephemeraltype (
ResponseType
|int
) – Which type of response should be sentallowed_mentions (
AllowedMentions
|None
) – Allowed mentions of the messagewait – Whether to wait for the message to be sent
thread_id – Thread ID to send the message to
tts (
bool
|None
) – Whether the message should be sent as TTSflags (
MessageFlags
|None
) – Flags of the messagedelete_after (
float
|None
) – How long to wait before deleting the message
- Return type:
- Returns:
Returns the message that was sent
- async delete_original_response() None ¶
Delete the original response to the interaction.
- Return type:
- async edit_original_response(*, content=<MISSING>, embed=<MISSING>, embeds=<MISSING>, view=<MISSING>, attachment=<MISSING>, attachments=<MISSING>, allowed_mentions=<MISSING>, flags=<MISSING>) WebhookMessage ¶
Edit the original response to the interaction.
- Return type:
- Parameters:
content (str | None)
embed (Embed | None)
view (View | None)
attachment (File | None)
allowed_mentions (AllowedMentions | None)
flags (MessageFlags | None)
- property guild: Guild | PartialGuild | None¶
Returns the guild the interaction was made in.
If you are using gateway cache, it can return full object too
- async original_response() WebhookMessage ¶
Fetch the original response to the interaction.
- Return type:
- property response: InteractionResponse¶
Returns the response to the interaction.
- async send(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, ephemeral=False, view=<MISSING>, tts=False, type=4, allowed_mentions=<MISSING>, poll=<MISSING>, flags=<MISSING>, delete_after=None) WebhookMessage ¶
Send a message after responding with an empty response in the initial interaction.
- Parameters:
ephemeral (
bool
|None
) – Whether the message should be sent as ephemeraltype (
ResponseType
|int
) – Which type of response should be sentallowed_mentions (
AllowedMentions
|None
) – Allowed mentions of the messagewait – Whether to wait for the message to be sent
thread_id – Thread ID to send the message to
tts (
bool
|None
) – Whether the message should be sent as TTSflags (
MessageFlags
|None
) – Flags of the messagedelete_after (
float
|None
) – How long to wait before deleting the message
- Return type:
- Returns:
Returns the message that was sent
- class discord_http.context.InteractionResponse(parent)¶
Bases:
object
- Parameters:
parent (Context)
- defer(ephemeral=False, thinking=False, flags=<MISSING>, call_after=None) DeferResponse ¶
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” statusflags (
MessageFlags
|None
) – The flags of the message (overrides ephemeral)call_after (
Callable
|None
) – A coroutine to run after the response is sent
- Return type:
- Returns:
The response to the interaction
- Raises:
TypeError – If call_after is not a coroutine
- edit_message(*, content=<MISSING>, embed=<MISSING>, embeds=<MISSING>, view=<MISSING>, attachment=<MISSING>, attachments=<MISSING>, allowed_mentions=<MISSING>, flags=<MISSING>, call_after=None) MessageResponse ¶
Edit the original message of the interaction.
- Parameters:
embeds (
list
[Embed
] |None
) – Multiple embeds to edit the message withattachment (
File
|None
) – New file to edit the message withattachments (
list
[File
] |None
) – Multiple new files to edit the message withallowed_mentions (
AllowedMentions
|None
) – Allowed mentions for the messageflags (
MessageFlags
|None
) – The flags of the messagecall_after (
Callable
|None
) – A coroutine to run after the response is sent
- Return type:
- Returns:
The response to the interaction
- Raises:
If both embed and embeds are passed - If both attachment and attachments are passed
TypeError – If call_after is not a coroutine
- pong() dict ¶
Only used to acknowledge a ping from Discord Developer portal Interaction URL.
- Return type:
- send_autocomplete(choices) AutocompleteResponse ¶
Send an autocomplete response to the interaction.
- Parameters:
- Return type:
- Returns:
The response to the interaction
- Raises:
If choices is not a dict - If choices is not a dict[str | int | float, str]
- send_empty(*, call_after=None) EmptyResponse ¶
Send an empty response to the interaction.
- send_message(content=<MISSING>, *, embed=<MISSING>, embeds=<MISSING>, file=<MISSING>, files=<MISSING>, ephemeral=False, view=<MISSING>, tts=False, type=4, allowed_mentions=<MISSING>, poll=<MISSING>, flags=<MISSING>, call_after=None) MessageResponse ¶
Send a message to the interaction.
- Parameters:
ephemeral (
bool
|None
) – If the message should be ephemeral (show only to the user)tts (
bool
|None
) – Whether the message should be sent using text-to-speechtype (
ResponseType
|int
) – The type of response to sendallowed_mentions (
AllowedMentions
|None
) – Allowed mentions for the messageflags (
MessageFlags
|None
) – The flags of the message (overrides ephemeral)call_after (
Callable
|None
) – A coroutine to run after the response is sent
- Return type:
- Returns:
The response to the interaction
- Raises:
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, *, call_after=None) ModalResponse ¶
Send a modal to the interaction.