aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mbaruh <[email protected]>2022-10-01 00:24:07 +0300
committerGravatar mbaruh <[email protected]>2022-10-01 00:24:07 +0300
commitb07e27638c85864e260df5d011c6f746a0f10948 (patch)
tree4895990a74e0b23090a35a199170323a743709de
parentCorrect logging (diff)
Use try-except instead of is_digit in bypass_roles
-rw-r--r--bot/exts/filtering/_settings_types/validations/bypass_roles.py7
1 files 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."""