Response

discord_http.response module

class discord_http.response.AutocompleteResponse(choices)

Bases: BaseResponse

Represents an autocomplete response.

Parameters:

choices (dict[Any, str]) – A dictionary of choices for the autocomplete response. The keys are the values to be sent to Discord, and the values are the names to be displayed to the user.

choices
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

Returns the content type of the response.

class discord_http.response.DeferResponse(*, ephemeral=False, thinking=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.

ephemeral
thinking
flags
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

Returns 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 (str | None) – The content of the message.

  • file (File | None) – A single file to be sent with the message.

  • files (list[File] | None) – A list of files to be sent with the message.

  • embed (Embed | None) – A single embed to be sent with the message.

  • embeds (list[Embed] | None) – A list of embeds to be sent with the message.

  • attachment (File | None) – A single attachment to be sent with the message.

  • attachments (list[File] | None) – A list of attachments to be sent with the message.

  • view (View | None) – A view to be sent with the message.

  • tts (bool | None) – Whether the message should be sent as a TTS 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.

  • type (ResponseType | int) – The type of the response. Defaults to ResponseType.message.

  • ephemeral (bool | None) – Whether the message should be ephemeral or not.

  • flags (MessageFlags | None) – Flags for the message response.

content
ephemeral
tts
type
allowed_mentions
message_reference
poll
flags
property content_type: str

Returns the content type of the response.

embeds
attachments
view
files
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

Returns the partial user object of the application.

property user: User

Returns the user object of the bot.

property created_at: datetime

The datetime of the snowflake.

id: int

The ID of the snowflake.