diff options
author | 2022-03-18 10:35:51 +0530 | |
---|---|---|
committer | 2022-03-18 10:38:46 +0530 | |
commit | 61feabb68feaf862e79d9a186c8346e961471183 (patch) | |
tree | 56e8e416c6846621a30077d4a5d164014719b99b | |
parent | rename function to be more generic (diff) |
try-except to prevent a TypeError instead of `if isinstance`
-rw-r--r-- | bot/decorators.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/decorators.py b/bot/decorators.py index a0390fc32..8971898b3 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -3,7 +3,6 @@ import functools import types import typing as t from contextlib import suppress -from datetime import datetime import arrow from discord import Member, NotFound @@ -259,7 +258,11 @@ def ensure_future_timestamp(timestamp_arg: function.Argument) -> t.Callable: ctx = function.get_arg_value(1, bound_args) - if isinstance(target, datetime) and target < arrow.utcnow(): + try: + is_future = target > arrow.utcnow() + except TypeError: + is_future = True + if not is_future: await ctx.send(":x: Provided timestamp is in the past.") return |