Pagination
Hello,
I'm currently experiencing an issue with pagination in my Discord.js bot, specifically related to updating the content of pages. Here's a brief overview of the problem:
I have implemented a pagination system that allows users to navigate through a list of items using previous and next buttons. Each page displays a limited number of items (let's say 5). The initial setup works fine, with the first page displaying the correct items. The second page displays the same objects as the first one and the third page shows the items 6-10 eventough i have 11 items so there's one item missing, which is showed when clicking on the previous page button to go back to page 2. However, when I delete an item on the last page, and the page becomes empty, the buttons for previous and next still appear, and the content of the page doesn't update accordingly. As a result, the pagination becomes inconsistent and doesn't reflect the actual state of the data.
I have reviewed my code and made attempts to fix the issue, but so far, I haven't been successful. I suspect there might be a problem with updating the currentPage and totalPages variables correctly when the page becomes empty.
I'm using discord.js v14.11.0 and node v18.15.0.
I'll attach a video of the problem and my code down below.
I would greatly appreciate any guidance or suggestions on how to resolve this issue. If there's any additional information or code that would be helpful, please let me know.
Thank you in advance for your assistance!
I'm currently experiencing an issue with pagination in my Discord.js bot, specifically related to updating the content of pages. Here's a brief overview of the problem:
I have implemented a pagination system that allows users to navigate through a list of items using previous and next buttons. Each page displays a limited number of items (let's say 5). The initial setup works fine, with the first page displaying the correct items. The second page displays the same objects as the first one and the third page shows the items 6-10 eventough i have 11 items so there's one item missing, which is showed when clicking on the previous page button to go back to page 2. However, when I delete an item on the last page, and the page becomes empty, the buttons for previous and next still appear, and the content of the page doesn't update accordingly. As a result, the pagination becomes inconsistent and doesn't reflect the actual state of the data.
I have reviewed my code and made attempts to fix the issue, but so far, I haven't been successful. I suspect there might be a problem with updating the currentPage and totalPages variables correctly when the page becomes empty.
I'm using discord.js v14.11.0 and node v18.15.0.
I'll attach a video of the problem and my code down below.
I would greatly appreciate any guidance or suggestions on how to resolve this issue. If there's any additional information or code that would be helpful, please let me know.
Thank you in advance for your assistance!