Http¶
Warning
This module is not meant to be used directly,
it is used internally by discord_http.Client
.
discord_http.http module¶
- class discord_http.http.DiscordAPI(*, client)¶
Bases:
object
- Parameters:
client (Client)
- async fetch_commands(guild_id=None) dict ¶
Fetches the commands for the bot.
- Parameters:
guild_id (
int
|None
) – The guild ID to fetch the commands for (if None, commands will be global)- Return type:
- Returns:
The response from the request
- Raises:
HTTPException – If the request returned anything other than 200. Typically this means the guild is not found.
- get_ratelimit(key) Ratelimit ¶
Get a ratelimit object from the bucket.
- Return type:
Ratelimit
- Parameters:
key (str)
- async me() UserClient ¶
Fetches the bot’s user information.
- Return type:
- Returns:
The bot’s user object
- Raises:
If the bot token is not valid - If the bot is not allowed to use the some intents
- async query(method, path, *, res_method='json', retry_codes=None, **kwargs) HTTPResponse ¶
Make a request to the Discord API.
- Parameters:
method (
Literal
['GET'
,'POST'
,'DELETE'
,'PUT'
,'HEAD'
,'PATCH'
,'OPTIONS'
]) – Which HTTP method to usepath (
str
) – The path to make the request tores_method (
Literal
['text'
,'read'
,'json'
]) – The method to use to get the responseretry_codes (
list
[int
] |None
) – The HTTP codes to retry regardless of the response**kwargs – The keyword arguments to pass to the aiohttp.ClientSession.request method
- Return type:
- Returns:
The response from the request
- Raises:
ValueError – Invalid HTTP method
DiscordServerError – Something went wrong on Discord’s end
Forbidden – You are not allowed to do this
NotFound – The resource was not found
HTTPException – Something went wrong
RuntimeError – Unreachable code, reached max tries (5)