Backend¶
discord_http.backend module¶
- class discord_http.backend.DiscordHTTP(*, client)¶
Bases:
ApplicationServes as the fundemental HTTP server for Discord Interactions.
We recommend to not touch this class, unless you know what you’re doing
- Parameters:
client (Client)
- debug_events¶
Whether to dispatch debug events for interactions received, defaults to False.
- verify_key: VerifyKey | None¶
The verify key used to validate incoming requests, if not set, it will try to fetch from the bot’s public key.
- ATTRS = frozenset({'_cleanup_ctx', '_client_max_size', '_debug', '_frozen', '_handler_args', '_has_legacy_middlewares', '_loop', '_middlewares', '_middlewares_handlers', '_on_cleanup', '_on_response_prepare', '_on_shutdown', '_on_startup', '_pre_frozen', '_router', '_run_middlewares', '_state', '_subapps', 'logger'})¶
- add_domain(domain, subapp) MatchedSubAppResource¶
- Return type:
MatchedSubAppResource- Parameters:
domain (str)
subapp (Application)
- add_subapp(prefix, subapp) PrefixedSubAppResource¶
- Return type:
PrefixedSubAppResource- Parameters:
prefix (str)
subapp (Application)
- property cleanup_ctx: CleanupContext¶
- clear() None. Remove all items from D.¶
- 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:
- Return type:
- Returns:
The message response provided by the library error handler
- items() a set-like object providing a view on D's items¶
- keys() a set-like object providing a view on D's keys¶
- property loop: AbstractEventLoop¶
- make_handler(*, loop=None, access_log_class=<class 'aiohttp.web_log.AccessLogger'>, **kwargs) Server¶
- Return type:
Server- Parameters:
loop (AbstractEventLoop | None)
access_log_class (Type[AbstractAccessLogger])
kwargs (Any)
- property middlewares: FrozenList¶
- property on_cleanup: Signal¶
- property on_response_prepare: Signal¶
- property on_shutdown: Signal¶
- property on_startup: Signal¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair¶
as a 2-tuple; but raise KeyError if D is empty.
- property router: UrlDispatcher¶
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D¶
- async startup() None¶
Causes on_startup signal
Should be called in the event loop along with the request handler.
- Return type:
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values¶
- async index_ping(_request) Response¶
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
- Parameters:
request – The incoming request object (not used by default)
_request (Request)
- Return type:
Response
- jsonify(data, *, status=200) Response¶
Respond with JSON data in a standardized way using orjson.
Serves as the replacement for aiohttp’s built-in json response.
- multipart_response(body, *, status=200) Response¶
Respond with multipart data in a standardized way.