Backend

discord_http.backend module

class discord_http.backend.DiscordHTTP(*, client)

Bases: Quart

Parameters:

client (Client)

error_messages(ctx, e) MessageResponse | None

Used to return error messages to Discord.

By default, it will only cover CheckFailed errors. You can overwrite this function to return your own error messages.

Parameters:
  • ctx (Context) – The context of the command

  • e (Exception) – The exception that was raised

Return type:

MessageResponse | None

Returns:

The message response provided by the library error handler

async index_ping() tuple[dict, int] | dict

Used to ping the interaction url, to check if it’s working.

You can overwrite this function to return your own data as well. Remember that it must return dict

Return type:

tuple[dict, int] | dict

jsonify(data, *, status=200, sort_keys=False, indent=None) Response

Force Quart to respond with JSON the way you like it.

Parameters:
  • data (dict) – The data to respond with

  • status (int) – The status code to respond with

  • sort_keys (bool) – Whether to sort the keys or not

  • indent (int | None) – If the JSON should be indented on response

Return type:

Response

Returns:

The response object

run(host, port, loop) None

## Do NOT use this function, use start instead.

Return type:

None

Parameters:
  • host (str)

  • port (int)

  • loop (AbstractEventLoop)

run_task(host='127.0.0.1', port=8080, shutdown_trigger=None) Coroutine[None, None, None]

## Do NOT use this function, use start instead.

Return type:

Coroutine[None, None, None]

Parameters:
  • host (str)

  • port (int)

  • shutdown_trigger (Any)

start(*, host='127.0.0.1', port=8080) None

Start the HTTP server.

Parameters:
  • host (str) – The IP address to bind to, by default 127.0.0.1

  • port (int) – The port to bind to, by default 8080

Return type:

None