Skip to content

Commit 28e1642

Browse files
committed
expose the pagination utils from the pydis_core package
1 parent 618d55e commit 28e1642

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

pydis_core/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pydis_core import async_stats, exts, site_api, utils
44
from pydis_core._bot import BotBase, StartupError
5+
from pydis_core.utils.pagination import EmptyPaginatorEmbedError, LinePaginator, PaginationEmojis
56

67
__all__ = [
78
async_stats,
@@ -10,6 +11,9 @@
1011
utils,
1112
site_api,
1213
StartupError,
14+
LinePaginator,
15+
PaginationEmojis,
16+
EmptyPaginatorEmbedError
1317
]
1418

1519
__all__ = [module.__name__ for module in __all__]

pydis_core/utils/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
interactions,
1212
logging,
1313
members,
14+
messages,
15+
pagination,
1416
paste_service,
1517
regex,
1618
scheduling,
@@ -45,6 +47,8 @@ def apply_monkey_patches() -> None:
4547
interactions,
4648
logging,
4749
members,
50+
messages,
51+
pagination,
4852
paste_service,
4953
regex,
5054
scheduling,

pydis_core/utils/paginator.py renamed to pydis_core/utils/pagination.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ async def paginate(
246246
>>> await LinePaginator.paginate(pagination_emojis, [line for line in lines], ctx, embed)
247247
"""
248248
paginator = cls(prefix=prefix, suffix=suffix, max_size=max_size,
249-
max_lines=max_lines, scale_to_size=scale_to_size, pagination_emojis=pagination_emojis)
249+
max_lines=max_lines, scale_to_size=scale_to_size)
250250
current_page = 0
251251

252252
if not restrict_to_user:
@@ -313,7 +313,7 @@ async def paginate(
313313

314314
log.debug("Adding emoji reactions to message...")
315315

316-
pagination_emoji = list(paginator.pagination_emojis.dict().values())
316+
pagination_emoji = list(pagination_emojis.model_dump().values())
317317

318318
for emoji in pagination_emoji:
319319
# Add all the applicable emoji to the message
@@ -339,7 +339,7 @@ async def paginate(
339339
log.debug("Timed out waiting for a reaction")
340340
break # We're done, no reactions for the last 5 minutes
341341

342-
if str(reaction.emoji) == paginator.pagination_emojis.delete:
342+
if str(reaction.emoji) == pagination_emojis.delete:
343343
log.debug("Got delete reaction")
344344
return await message.delete()
345345
if reaction.emoji in pagination_emoji:
@@ -351,20 +351,20 @@ async def paginate(
351351
if e.code != 50083:
352352
raise e
353353

354-
if reaction.emoji == paginator.pagination_emojis.first:
354+
if reaction.emoji == pagination_emojis.first:
355355
current_page = 0
356356
log.debug(f"Got first page reaction - changing to page 1/{total_pages}")
357-
elif reaction.emoji == paginator.pagination_emojis.last:
357+
elif reaction.emoji == pagination_emojis.last:
358358
current_page = len(paginator.pages) - 1
359359
log.debug(f"Got last page reaction - changing to page {current_page + 1}/{total_pages}")
360-
elif reaction.emoji == paginator.pagination_emojis.left:
360+
elif reaction.emoji == pagination_emojis.left:
361361
if current_page <= 0:
362362
log.debug("Got previous page reaction, but we're on the first page - ignoring")
363363
continue
364364

365365
current_page -= 1
366366
log.debug(f"Got previous page reaction - changing to page {current_page + 1}/{total_pages}")
367-
elif reaction.emoji == paginator.pagination_emojis.right:
367+
elif reaction.emoji == pagination_emojis.right:
368368
if current_page >= len(paginator.pages) - 1:
369369
log.debug("Got next page reaction, but we're on the last page - ignoring")
370370
continue

0 commit comments

Comments
 (0)