Tasks¶
discord_http.tasks module¶
- class discord_http.tasks.Sleeper(dt, *, loop)¶
Bases:
objectA helper class that handles sleeping until a specified datetime.
- Parameters:
dt (datetime)
loop (AbstractEventLoop)
- loop¶
The event loop that the sleeper is using.
- future: Future¶
The future that is waiting for the timer to finish.
- handle: TimerHandle¶
The handle for the timer that is waiting for the specified datetime.
- wait() Future¶
Wait for the timer to finish.
- Return type:
Future- Returns:
The future that is waiting for the timer to finish
- class discord_http.tasks.Loop(*, func, seconds, minutes, hours, time=None, count=None, reconnect=True)¶
Bases:
objectA helper class that handles looping a function at a specified interval.
- Parameters:
- start(*args, **kwargs) Task¶
Starts the loop.
- Return type:
Task
- before_loop() Callable¶
Decorator that registers a custom before_loop handler for the loop.
- Return type:
- after_loop() Callable¶
Decorator that registers a custom after_loop handler for the loop.
- Return type:
- remove_exception(*exceptions) None¶
Removes exceptions from the whitelist of exceptions that are ignored.
- reset_exceptions() None¶
Resets the whitelist of exceptions that are ignored back to the default.
- Return type:
- discord_http.tasks.loop(*, seconds=None, minutes=None, hours=None, time=None, count=None, reconnect=True) Callable[[Callable], Loop]¶
Decorator that registers a function as a loop.
- Parameters:
seconds (
float|None) – The number of seconds between each iteration of the loop.minutes (
float|None) – The number of minutes between each iteration of the loop.hours (
float|None) – The number of hours between each iteration of the loop.time (
time|list[time] |None) – The time of day to run the loop at. (UTC only)count (
int|None) – The number of times to run the loop. IfNone, the loop will run forever.reconnect (
bool) – Whether the loop should reconnect if it fails or not.
- Return type: