dico.http.async_http module
- class dico.http.async_http.AsyncHTTPRequest(token, loop=None, session=None, default_retry=3)
Bases:
HTTPRequestBaseAsync HTTP request client.
Warning
This module isn’t intended to be directly used. It is recommended to request via APIClient.
- Parameters:
token – Application token to use.
loop – AsyncIO loop instance to use. Default
asyncio.get_event_loop().session – Optional ClientSession to use.
default_retry – Maximum retry count. Default 3.
- Variables:
token – Application token of the client.
logger – Logger instance of the client.
session – ClientSession of the client.
default_retry – Maximum retry count of the client.
ratelimits –
ratelimit.RatelimitHandlerof the client.
- async close()
Closes session and marks this client as closed.
- async request(route, meth, body=None, *, is_json=False, reason_header=None, retry=None, **kwargs)
Sends request to Discord API.
- Parameters:
route – Route to request.
meth – Method to use.
body – Body of the request.
is_json – Whether the body is JSON.
reason_header – Reason to show in audit log.
retry – Retry count in rate limited situation.
kwargs – Extra options to add.
- Returns:
Response.
- Raises:
BadRequest – This request is incorrect.
Forbidden – You do not have permission for this action.
DiscordError – Something is wrong with Discord right now.
Unknown – We are unable to handle this error, sorry.
RateLimited – We are rate limited, please try again later.
- create_message_with_files(channel_id, content=None, files=None, nonce=None, tts=None, embeds=None, allowed_mentions=None, message_reference=None, components=None, sticker_ids=None, attachments=None)
Sends create message request with files.
- Parameters:
channel_id – ID of the channel.
content – Content of the message.
files – Files of the message.
nonce –
tts – Whether this message is TTS.
embeds – List of embeds of the message.
allowed_mentions – Allowed mentions of the message.
message_reference – Message to reference.
components – Components of the message.
sticker_ids – List of ID of the stickers.
attachments – List of attachment objects.
- edit_message_with_files(channel_id, message_id, content=Empty, embeds=Empty, flags=Empty, files=Empty, allowed_mentions=Empty, attachments=Empty, components=Empty)
Sends edit message request with files.
- Parameters:
channel_id – ID of the channel.
message_id – ID of the message to edit.
content – Content of the message.
embeds – List of embeds of the message.
flags – Flags of the message.
files – Files of the message.
allowed_mentions – Allowed mentions of the message.
attachments – Attachments to keep.
components – Components of the message.
- Returns:
Message object dict.
- create_guild_sticker(guild_id, name, description, tags, file, reason=None)
Sends create guild sticker request.
- Parameters:
guild_id – ID of the guild.
name – Name of the sticker.
description – Description of the sticker.
tags – Autocomplete text.
file – Sticker file to upload. Max 500 KB.
reason – Reason of the action.
- execute_webhook_with_files(webhook_id, webhook_token, wait=None, thread_id=None, content=None, username=None, avatar_url=None, tts=False, files=None, embeds=None, allowed_mentions=None, components=None, attachments=None, flags=None)
Sends execute webhook request with files.
- Parameters:
webhook_id – ID of the webhook.
webhook_token – Token of the webhook.
wait – Whether to wait response of the server.
thread_id – ID of the thread.
content – Content of the message.
username – Name of the webhook.
avatar_url – URL of the avatar image.
tts – Whether this message is TTS.
files – Files of the message.
embeds – List of embeds of the message.
allowed_mentions – Allowed mentions of the message.
components – Components of the message.
attachments – List of attachment objects.
flags – Flags of the message.
- edit_webhook_message(webhook_id, webhook_token, message_id, content=Empty, embeds=Empty, files=Empty, allowed_mentions=Empty, attachments=Empty, components=Empty)
Sends edit webhook message request. :param webhook_id: ID of the webhook. :param webhook_token: Token of the webhook. :param message_id: ID of the message to edit. :param content: Content of the message. :param embeds: List of embed of the message. :param files: Files of the message. :param allowed_mentions: Allowed mentions of the message. :param attachments: Attachments to keep. :param components: Components of the message.
- async download(url)
Downloads file from passed url.
- Parameters:
url – URL to download.
- classmethod create(token, loop=None, session=None, default_retry=3)
Creates new HTTP request client.
- Parameters:
token – Token of the bot.
args – Extra optional args.
kwargs – Extra optional keyword args.
- Returns:
Initialized object.