AutoPost API Reference#

class AutoPost(client)[source]#

Bases: object

You can use this to post stats automatically.

Parameters:

client (BoticordClient) – An instance of BoticordClient.

property is_running: bool#

Is autopost running?

on_success(callback: Any | None = None)[source]#

Registers success callback.

Warning

Callback functions must be a coroutine. If they aren’t, then you might get unexpected errors. In order to turn a function into a coroutine they must be async def functions.

This method can be used as a decorator (if you want).

on_error(callback: Any | None = None)[source]#

Registers error callback.

Warning

Callback functions must be a coroutine. If they aren’t, then you might get unexpected errors. In order to turn a function into a coroutine they must be async def functions.

The callback function requires to take Exception argument. This method can be used as a decorator (if you want).

init_stats(callback: Any | None = None)[source]#

Registers a function that will return stats. Registered Function Must return dictionary.

Warning

None of the values must be equal to 0. Specify None instead of 0.

Warning

Callback functions must be a coroutine. If they aren’t, then you might get unexpected errors. In order to turn a function into a coroutine they must be async def functions.

This method can be used as a decorator (if you want).

property interval: float#

The interval between posting stats.

set_interval(seconds: int) AutoPost[source]#

Sets the interval between posting stats.

Parameters:

seconds (int) – The interval.

Raises:

ValueError – Boticord recommends not to set interval lower than 900 seconds!

start(bot_id: str | int)[source]#

Starts the loop.

Parameters:

bot_id (Union[int, str]) – Id of the bot to send stats of.

Raises:

InternalException – If there’s no callback (for getting stats) provided or the autopost is already running.

stop() None[source]#

Stops the autopost.