API Reference¶
The following section outlines the API of danbot-hosting-py.
Client¶
-
class
danbot_api.
DanBotClient
(bot: discord.client.Client, *, key: str, session: Optional[aiohttp.client.ClientSession] = None, autopost: bool = False)¶ Represents a client connection that connects to the DanBotHosting API.
- Parameters
bot (Union[discord.Client, discord.ext.commands.Bot])) – your discord.py client connection.
key (str) – the DanBot Hosting API key.
autopost (bool, default: False) – If you want to have autopost turned on/off.
session (Optional[aiohttp.ClientSession]) – If you want to have a custom ClientSession instance for sending requests.
-
async
post
(server_count: int, user_count: int)¶ Main post method
You don’t need to use this method if you have the autopost paremeter in the class set to True.
-
async
close
()¶ Closes all of the connections.
Exceptions¶
-
exception
danbot_api.
DBHException
¶ Bases:
Exception
Base exception class for this module
So all of the errors/exceptions below/after this would be a subclass of this
-
exception
danbot_api.
HTTPException
¶ Bases:
danbot_api.errors.DBHException
The exception for the http errors
-
exception
danbot_api.
ServerError
(status_code: int)¶ Bases:
danbot_api.errors.HTTPException
Gives you this error when the response status is higher than 500
-
exception
danbot_api.
APIError
(msg)¶ Bases:
danbot_api.errors.HTTPException
Given when the API itself gives out an error