aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Boris Muratov <[email protected]>2021-02-26 14:48:10 +0200
committerGravatar Boris Muratov <[email protected]>2021-02-26 14:48:10 +0200
commitcea82da9547d3178f071241a75d024582d314ff9 (patch)
tree1646581c4a3a619bf43f984ae86ed2f8956083ec
parentRetain 'd' alias for threshold command (diff)
Supressing any exceptions while updating the threshold in redis
Updating redis might cause an error, making sure it doesn't stop the command mid-way
-rw-r--r--bot/exts/moderation/defcon.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/bot/exts/moderation/defcon.py b/bot/exts/moderation/defcon.py
index 86dece518..a88892b13 100644
--- a/bot/exts/moderation/defcon.py
+++ b/bot/exts/moderation/defcon.py
@@ -2,6 +2,7 @@ import asyncio
import logging
import traceback
from collections import namedtuple
+from contextlib import suppress
from datetime import datetime
from enum import Enum
from typing import Optional, Union
@@ -208,12 +209,13 @@ class Defcon(Cog):
if self.expiry is not None:
self.scheduler.schedule_at(expiry, 0, self._remove_threshold())
- await self.defcon_settings.update(
- {
- 'threshold': Defcon._stringify_relativedelta(self.threshold) if self.threshold else "",
- 'expiry': expiry.isoformat() if expiry else 0
- }
- )
+ with suppress(Exception):
+ await self.defcon_settings.update(
+ {
+ 'threshold': Defcon._stringify_relativedelta(self.threshold) if self.threshold else "",
+ 'expiry': expiry.isoformat() if expiry else 0
+ }
+ )
self._update_notifier()
action = Action.DURATION_UPDATE