From 7f22d27d51a6a9b64b088fa1b148ec35dabe5b7c Mon Sep 17 00:00:00 2001 From: Flame442 <34169552+Flame442@users.noreply.github.com> Date: Wed, 18 Sep 2019 17:15:24 -0400 Subject: [PATCH] Fixes the logic of MessagePredicate.greater and MessagePredicate.less (#3004) * Fixes the logic of MessagePredicate.greater and MessagePredicate.less * Create 3004.bugfix.rst --- changelog.d/3004.bugfix.rst | 1 + redbot/core/utils/predicates.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog.d/3004.bugfix.rst diff --git a/changelog.d/3004.bugfix.rst b/changelog.d/3004.bugfix.rst new file mode 100644 index 000000000..05e31452f --- /dev/null +++ b/changelog.d/3004.bugfix.rst @@ -0,0 +1 @@ +Fixed MessagePredicate.greater and MessagePredicate.less allowing any valid int instead of only valid ints/floats that are greater/less than the given value. diff --git a/redbot/core/utils/predicates.py b/redbot/core/utils/predicates.py index 5b311a55e..2b35c5051 100644 --- a/redbot/core/utils/predicates.py +++ b/redbot/core/utils/predicates.py @@ -574,7 +574,7 @@ class MessagePredicate(Callable[[discord.Message], bool]): """ valid_int = cls.valid_int(ctx, channel, user) valid_float = cls.valid_float(ctx, channel, user) - return cls(lambda self, m: valid_int(m) or valid_float(m) and float(m.content) < value) + return cls(lambda self, m: (valid_int(m) or valid_float(m)) and float(m.content) < value) @classmethod def greater( @@ -605,7 +605,7 @@ class MessagePredicate(Callable[[discord.Message], bool]): """ valid_int = cls.valid_int(ctx, channel, user) valid_float = cls.valid_float(ctx, channel, user) - return cls(lambda self, m: valid_int(m) or valid_float(m) and float(m.content) > value) + return cls(lambda self, m: (valid_int(m) or valid_float(m)) and float(m.content) > value) @classmethod def length_less(