Response

discord_http.response module

class discord_http.response.AutocompleteResponse(choices)

Bases: BaseResponse

Represents an autocomplete response.

Parameters:

choices (dict[Any, str])

choices

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.DeferResponse(*, thinking=False, ephemeral=False, flags=None)

Bases: BaseResponse

Represents a response that defers the interaction.

Parameters:
ephemeral

Whether the response is ephemeral or not.

thinking

Whether the response is thinking or not.

flags

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.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>)

Bases: BaseResponse

Represents a message response.

Parameters:
content

The content of the message.

property content_type: str

The content type of the response.

ephemeral

Whether the message should be ephemeral or not.

tts

Whether the message should be sent as a TTS message.

type

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

allowed_mentions

Allowed mentions for the message.

message_reference

A reference to another message, if applicable.

poll

A poll to be sent with the message.

flags

Flags for the message response.

embeds

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

attachments

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

view

A view to be sent with the message.

files

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_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.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.