Tasks¶
discord_http.tasks module¶
- class discord_http.tasks.Loop(*, func, seconds, minutes, hours, time=None, count=None, reconnect=True)¶
Bases:
object
- Parameters:
- after_loop() Callable ¶
Decorator that registers a custom after_loop handler for the loop.
- Return type:
- before_loop() Callable ¶
Decorator that registers a custom before_loop handler for the loop.
- Return type:
- handle_interval(*, seconds=0, minutes=0, hours=0, time=None) None ¶
Sets the interval of the loop.
- Parameters:
- Raises:
The sleep timer cannot be 0 - count must be greater than 0 or None
TypeError – time must be a datetime.time object
- 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:
- start(*args, **kwargs) Task ¶
Starts the loop.
- Return type:
Task
- class discord_http.tasks.Sleeper(dt, *, loop)¶
Bases:
object
- Parameters:
dt (datetime)
loop (AbstractEventLoop)
- done() bool ¶
Returns whether the timer is done or not.
- Return type:
- Returns:
Whether the timer is done or not
- wait() Future ¶
Wait for the timer to finish.
- Return type:
Future
- Returns:
The future that is waiting for the timer to finish
- 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: