mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Prevent an IndexError from occuring (#5430)
* 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 👍
This commit is contained in:
parent
22df591db2
commit
60b495091a
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user