Tasks¶
discord_http.tasks module¶
- class discord_http.tasks.Loop(*, func: Callable, seconds: float | None, minutes: float | None, hours: float | None, time: time | list[time] | None = None, count: int | None = None, reconnect: bool = True)[source]¶
Bases:
object
- add_exception(*exceptions: Exception) None [source]¶
Adds exceptions to the whitelist of exceptions that are ignored
- property failed: bool¶
Returns whether the loop has failed or not
- handle_interval(*, seconds: float | None = 0, minutes: float | None = 0, hours: float | None = 0, time: time | list[time] | None = None) None [source]¶
Sets the interval of the loop.
- Parameters:
seconds (float) – Amount of seconds between each iteration of the loop
minutes (float) – Amount of minutes between each iteration of the loop
hours (float) – Amount of hours between each iteration of the loop
time (dtime) – The time of day to run the loop at
- Raises:
ValueError –
The sleep timer cannot be 0 - count must be greater than 0 or None
TypeError – time must be a datetime.time object
- property loop_count: int¶
Returns the number of times the loop has been run
- remove_exception(*exceptions: Exception) None [source]¶
Removes exceptions from the whitelist of exceptions that are ignored
- discord_http.tasks.loop(*, seconds: float | None = None, minutes: float | None = None, hours: float | None = None, time: time | list[time] | None = None, count: int | None = None, reconnect: bool = True) Callable[[Callable], Loop] [source]¶
Decorator that registers a function as a loop.
- Parameters:
seconds (float) – The number of seconds between each iteration of the loop.
minutes (float) – The number of minutes between each iteration of the loop.
hours (float) – The number of hours between each iteration of the loop.
time (datetime.time) – The time of day to run the loop at. (UTC only)
count (int) – The number of times to run the loop. If
None
, the loop will run forever.reconnect (bool) – Whether the loop should reconnect if it fails or not.