Conditions | 3 |
Total Lines | 24 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | """Cog for tasks that are scheduled to run""" |
||
22 | @tasks.loop(hours=24.0) |
||
23 | async def report_errors(self) -> None: |
||
24 | """ |
||
25 | Report error |
||
26 | |||
27 | Every 24 hours, all errors for the current day are send to the admin channels. |
||
28 | |||
29 | :return: None |
||
30 | """ |
||
31 | date = datetime.utcnow().strftime("%Y-%m-%d") |
||
32 | error_record = [ |
||
33 | error |
||
34 | for error in await utils.select( |
||
35 | "errors", "id, message, error, ack", "date_trunc('day', time)", date |
||
36 | ) |
||
37 | if error[-1] is False |
||
38 | ] |
||
39 | if not error_record: |
||
40 | errors = f"No errors found for {date}" |
||
41 | else: |
||
42 | errors = f"Errors for {date}.\n" |
||
43 | for error in error_record: |
||
44 | errors += f"- {error[0]}: {error[1]}; {error[2]}\n\n" |
||
45 | await utils.admin_log(self.bot, errors, True) |
||
46 | |||
51 |