From 61feabb68feaf862e79d9a186c8346e961471183 Mon Sep 17 00:00:00 2001 From: Shakya Majumdar Date: Fri, 18 Mar 2022 10:35:51 +0530 Subject: try-except to prevent a TypeError instead of `if isinstance` --- bot/decorators.py | 7 +++++-- 1 file 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 -- cgit v1.2.3