From b07e27638c85864e260df5d011c6f746a0f10948 Mon Sep 17 00:00:00 2001 From: mbaruh Date: Sat, 1 Oct 2022 00:24:07 +0300 Subject: Use try-except instead of is_digit in bypass_roles --- bot/exts/filtering/_settings_types/validations/bypass_roles.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bot/exts/filtering/_settings_types/validations/bypass_roles.py b/bot/exts/filtering/_settings_types/validations/bypass_roles.py index c1e6f885d..193b07e13 100644 --- a/bot/exts/filtering/_settings_types/validations/bypass_roles.py +++ b/bot/exts/filtering/_settings_types/validations/bypass_roles.py @@ -18,10 +18,11 @@ class RoleBypass(ValidationEntry): @validator("bypass_roles", pre=True, each_item=True) @classmethod def maybe_cast_to_int(cls, role: str) -> Union[int, str]: - """If the string is alphanumeric, cast it to int.""" - if role.isdigit(): + """If the string is numeric, cast it to int.""" + try: return int(role) - return role + except ValueError: + return role def triggers_on(self, ctx: FilterContext) -> bool: """Return whether the filter should be triggered on this user given their roles.""" -- cgit v1.2.3