From 60b495091a4da417df94e90a6c8e0df3a5d07eb7 Mon Sep 17 00:00:00 2001 From: Kowlin <10947836+Kowlin@users.noreply.github.com> Date: Sat, 16 Apr 2022 23:05:57 +0200 Subject: [PATCH] Prevent an IndexError from occuring (#5430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Prevent an IndexError from occuring If an page value is negative it doesn't properly loop around to the end. * Update menus.py * I'm smart 👍 --- redbot/core/utils/menus.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/redbot/core/utils/menus.py b/redbot/core/utils/menus.py index 871f3bab2..a78e9633f 100644 --- a/redbot/core/utils/menus.py +++ b/redbot/core/utils/menus.py @@ -155,7 +155,7 @@ async def next_page( Function for showing next page which is suitable for use in ``controls`` mapping that is passed to `menu()`. """ - if page == len(pages) - 1: + if page >= len(pages) - 1: page = 0 # Loop around to the first item else: page = page + 1 @@ -175,7 +175,7 @@ async def prev_page( Function for showing previous page which is suitable for use in ``controls`` mapping that is passed to `menu()`. """ - if page == 0: + if page <= 0: page = len(pages) - 1 # Loop around to the last item else: page = page - 1