Response

discord_http.response module

class discord_http.response.AutocompleteResponse(choices)

Bases: BaseResponse

Represents an autocomplete response.

Parameters:

choices (dict[Any, str])

choices: dict[Any, str]

A dictionary of choices, where keys are sent to Discord and values are shown to the user.

to_dict() → dict

Returns the response as a dict.

Return type:

dict

to_multipart() → MultipartWriter

Returns the multipart data.

Return type:

MultipartWriter

property content_type: str

The content type of the response.

class discord_http.response.BaseResponse

Bases: object

Represents a base response for interactions.

property content_type: str

The content type of the response.

to_dict() → dict

Default method to convert the response to a dict.

Return type:

dict

to_multipart() → bytes

Default method to covnert the response to multipart data.

Return type:

bytes

class discord_http.response.DeferResponse(*, thinking=False, ephemeral=False, flags=None)

Bases: BaseResponse

Represents a response that defers the interaction.

Parameters:
ephemeral: bool

Whether the response is ephemeral or not.

thinking: bool

Whether the response is thinking or not.

flags: MessageFlags

The flags for the response.

to_dict() → dict

Returns the response as a dict.

Return type:

dict

to_multipart() → MultipartWriter

Returns the multipart data.

Return type:

MultipartWriter

property content_type: str

The content type of the response.

class discord_http.response.EmptyResponse

Bases: BaseResponse

Represents an empty response.

This is used when no data is needed to be sent back to Discord. Instead, you respond later with a normal message.

to_dict() → dict

Returns the response as a dict.

Return type:

dict

to_multipart() → bytes

Returns the multipart data.

Return type:

bytes

property content_type: str

The content type of the response.

class discord_http.response.MessageResponse(content=<MISSING>, *, file=<MISSING>, files=<MISSING>, embed=<MISSING>, embeds=<MISSING>, attachment=<MISSING>, attachments=<MISSING>, view=<MISSING>, tts=False, allowed_mentions=<MISSING>, message_reference=<MISSING>, poll=<MISSING>, type=4, ephemeral=False, flags=<MISSING>, stickers=<MISSING>, nonce=<MISSING>, enforce_nonce=False, shared_client_theme=<MISSING>)

Bases: BaseResponse

Represents a message response.

Parameters:
content: str | None

The content of the message.

ephemeral: bool | None

Whether the message should be ephemeral or not.

property content_type: str

The content type of the response.

tts: bool | None

Whether the message should be sent as a TTS message.

type: ResponseType | int

The type of the response. Defaults to ResponseType.message.

allowed_mentions: AllowedMentions | None

Allowed mentions for the message.

message_reference: MessageReference | None

A reference to another message, if applicable.

poll: Poll | None

A poll to be sent with the message.

flags: MessageFlags

Flags for the message response.

stickers: list[PartialSticker | Snowflake | int] | None

Stickers from the guild to be sent with the message.

nonce: int | str | None

A nonce to verify the message was sent.

enforce_nonce: bool

Whether the nonce should be checked for uniqueness.

shared_client_theme: SharedClientTheme | None

A client theme to be shared with the message.

embeds: list[Embed] | None

The embeds to be sent with the message. A single embed may be passed via embed instead.

attachments: list[File] | None

The attachments to be sent with the message. A single attachment may be passed via attachment instead.

view: View | None

A view to be sent with the message.

files: list[File] | None

The files to be sent with the message. A single file may be passed via file instead.

to_dict(is_request=False) → dict

The JSON data that is sent to Discord.

Parameters:

is_request (bool) – Whether the data is being sent to Discord or not.

Return type:

dict

Returns:

The JSON data that can either be sent to Discord or forwarded to a new parser

to_request() → dict[str, Any]

The keyword arguments used to send the message to Discord with DiscordAPI.query().

Plain JSON is sent unless the message has files, since multipart data is a lot slower to build and send.

Return type:

dict[str, Any]

Returns:

Either the json body, or the multipart data and its headers

to_multipart(is_request=False) → MultipartWriter

The multipart data that is sent to Discord.

Parameters:

is_request (bool) – Whether the data is being sent to Discord or not.

Return type:

MultipartWriter

Returns:

The multipart data that can either be sent to Discord or forwarded to a new parser

class discord_http.response.ModalResponse(modal)

Bases: BaseResponse

Represents a modal response.

Parameters:

modal (Modal)

modal: Modal

The modal to be displayed to the user.

to_dict() → dict

Returns the response as a dict.

Return type:

dict

to_multipart() → MultipartWriter

Returns the multipart data.

Return type:

MultipartWriter

property content_type: str

The content type of the response.

class discord_http.response.Ping(*, state, data)

Bases: Snowflake

Represents a ping response from the Discord API.

Usually reserved for internal use.

Parameters:
application_id: int

The ID of the application that created the ping.

version: int

The version of the ping.

property application: PartialUser

The partial user object of the application.

property user: User

The user object of the bot.

property created_at: datetime

The datetime of the snowflake.

id: int

The ID of the snowflake.