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