diff options
author | 2025-03-18 21:49:07 -0300 | |
---|---|---|
committer | 2025-03-18 21:49:07 -0300 | |
commit | 6d3cbfbcfe904468faf05f24eb12894ef9bba838 (patch) | |
tree | 913106c14bb3a96fdf199fb673243325e4dd4156 | |
parent | Allows for end_index == len(zen_lines). Previously, in that case, end_index %... (diff) |
Allows for slicing without a specified end index (e.g. "1:" will return all lines from the second to the last)
-rw-r--r-- | bot/exts/utils/utils.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/bot/exts/utils/utils.py b/bot/exts/utils/utils.py index 473d860d0..e1443ee66 100644 --- a/bot/exts/utils/utils.py +++ b/bot/exts/utils/utils.py @@ -111,7 +111,7 @@ class Utils(Cog): zen_lines = ZEN_OF_PYTHON.splitlines() # Prioritize checking for an index or slice - match = re.match(r"(-?\d+)(:-?\d+)?", search_value.split(" ")[0]) + match = re.match(r"(-?\d+)(:(-?\d+)?)?", search_value.split(" ")[0]) if match: upper_bound = len(zen_lines) - 1 lower_bound = -1 * len(zen_lines) @@ -126,7 +126,7 @@ class Utils(Cog): await ctx.send(embed=embed) return - end_index=int(match.group(2)[1:]) + end_index= int(match.group(3)) if match.group(3) else len(zen_lines) if not ((lower_bound <= start_index <= upper_bound) and (lower_bound <= end_index <= len(zen_lines))): raise BadArgument(f"Please provide valid indices between {lower_bound} and {upper_bound}.") |