From abda846ca32bfa1276d299b8ab93b8980921c05b Mon Sep 17 00:00:00 2001 From: Ske Date: Fri, 8 Mar 2019 16:07:05 +0100 Subject: [PATCH] Fixed pagination page count calculation. --- src/pluralkit/bot/commands/system_commands.py | 5 +++-- src/pluralkit/bot/embeds.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pluralkit/bot/commands/system_commands.py b/src/pluralkit/bot/commands/system_commands.py index 2e86ac59..4399d33d 100644 --- a/src/pluralkit/bot/commands/system_commands.py +++ b/src/pluralkit/bot/commands/system_commands.py @@ -3,6 +3,7 @@ from datetime import datetime, timedelta import aiohttp import dateparser import humanize +import math import timezonefinder import pytz @@ -370,9 +371,9 @@ async def system_list(ctx: CommandContext, system: System): current_page = 0 msg: discord.Message = None while True: - page_count = len(all_members) // page_size + page_count = math.ceil(len(all_members) / page_size) embed = embeds.member_list(await ctx.get_system(), all_members, current_page) - + # Add reactions for moving back and forth if not msg: msg = await ctx.reply(embed=embed) diff --git a/src/pluralkit/bot/embeds.py b/src/pluralkit/bot/embeds.py index 6eb8f290..739aada9 100644 --- a/src/pluralkit/bot/embeds.py +++ b/src/pluralkit/bot/embeds.py @@ -1,4 +1,5 @@ import discord +import math import humanize from typing import Tuple, List @@ -219,7 +220,7 @@ def help_footer_embed() -> discord.Embed: return embed def member_list(system: System, all_members: List[Member], current_page: int = 0, page_size: int = 10): - page_count = len(all_members) // page_size + page_count = math.ceil(len(all_members) / page_size) title = "" if len(all_members) > page_size: