Skip to content

Commit bef1437

Browse files
committed
Paginator change
1 parent c89ce14 commit bef1437

File tree

5 files changed

+81
-239
lines changed

5 files changed

+81
-239
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ however, insignificant breaking changes does not guarantee a major version bump,
6666
- Use discord tasks for metadata loop.
6767
- More debug based logging.
6868
- Reduce redundancies in `?perms` sub commands.
69-
69+
- paginator been split into `EmbedPaginatorSession` and `MessagePaginatorSession`, both subclassing `PaginatorSession`.
70+
7071
# v3.0.3
7172

7273
### Added

cogs/modmail.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from core import checks
1616
from core.decorators import trigger_typing
1717
from core.models import PermissionLevel
18-
from core.paginator import PaginatorSession
18+
from core.paginator import EmbedPaginatorSession
1919
from core.time import UserFriendlyTime, human_timedelta
2020
from core.utils import format_preview, User, create_not_found_embed, format_description
2121

@@ -154,7 +154,7 @@ async def snippet(self, ctx, *, name: str.lower = None):
154154
embed.set_author(name="Snippets", icon_url=ctx.guild.icon_url)
155155
embeds.append(embed)
156156

157-
session = PaginatorSession(ctx, *embeds)
157+
session = EmbedPaginatorSession(ctx, *embeds)
158158
await session.run()
159159

160160
@snippet.command(name="raw")
@@ -631,7 +631,7 @@ async def logs(self, ctx, *, user: User = None):
631631

632632
embeds = self.format_log_embeds(logs, avatar_url=icon_url)
633633

634-
session = PaginatorSession(ctx, *embeds)
634+
session = EmbedPaginatorSession(ctx, *embeds)
635635
await session.run()
636636

637637
@logs.command(name="closed-by", aliases=["closeby"])
@@ -664,7 +664,7 @@ async def logs_closed_by(self, ctx, *, user: User = None):
664664
)
665665
return await ctx.send(embed=embed)
666666

667-
session = PaginatorSession(ctx, *embeds)
667+
session = EmbedPaginatorSession(ctx, *embeds)
668668
await session.run()
669669

670670
@logs.command(name="search", aliases=["find"])
@@ -697,7 +697,7 @@ async def logs_search(self, ctx, limit: Optional[int] = None, *, query):
697697
)
698698
return await ctx.send(embed=embed)
699699

700-
session = PaginatorSession(ctx, *embeds)
700+
session = EmbedPaginatorSession(ctx, *embeds)
701701
await session.run()
702702

703703
@commands.command()
@@ -893,7 +893,8 @@ async def blocked(self, ctx):
893893
else:
894894
embeds[-1].description = "Currently there are no blocked users."
895895

896-
await PaginatorSession(ctx, *embeds).run()
896+
session = EmbedPaginatorSession(ctx, *embeds)
897+
await session.run()
897898

898899
@blocked.command(name="whitelist")
899900
@checks.has_permissions(PermissionLevel.MODERATOR)

cogs/plugins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from core import checks
1919
from core.models import PermissionLevel
20-
from core.paginator import PaginatorSession
20+
from core.paginator import EmbedPaginatorSession
2121

2222
logger = logging.getLogger("Modmail")
2323

@@ -465,7 +465,7 @@ async def plugin_registry(self, ctx, *, plugin_name: typing.Union[int, str] = No
465465

466466
embeds.append(embed)
467467

468-
paginator = PaginatorSession(ctx, *embeds)
468+
paginator = EmbedPaginatorSession(ctx, *embeds)
469469
paginator.current = index
470470
await paginator.run()
471471

@@ -499,7 +499,7 @@ async def plugin_registry_compact(self, ctx):
499499
embed.set_author(name="Plugin Registry", icon_url=self.bot.user.avatar_url)
500500
embeds.append(embed)
501501

502-
paginator = PaginatorSession(ctx, *embeds)
502+
paginator = EmbedPaginatorSession(ctx, *embeds)
503503
await paginator.run()
504504

505505

cogs/utility.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from core.changelog import Changelog
2727
from core.decorators import trigger_typing
2828
from core.models import InvalidConfigError, PermissionLevel
29-
from core.paginator import PaginatorSession, MessagePaginatorSession
29+
from core.paginator import EmbedPaginatorSession, MessagePaginatorSession
3030
from core.utils import (
3131
cleanup_code,
3232
User,
@@ -112,17 +112,17 @@ async def send_bot_help(self, mapping):
112112
if no_cog_commands:
113113
embeds.extend(await self.format_cog_help(no_cog_commands, no_cog=True))
114114

115-
p_session = PaginatorSession(
115+
session = EmbedPaginatorSession(
116116
self.context, *embeds, destination=self.get_destination()
117117
)
118-
return await p_session.run()
118+
return await session.run()
119119

120120
async def send_cog_help(self, cog):
121121
embeds = await self.format_cog_help(cog)
122-
p_session = PaginatorSession(
122+
session = EmbedPaginatorSession(
123123
self.context, *embeds, destination=self.get_destination()
124124
)
125-
return await p_session.run()
125+
return await session.run()
126126

127127
async def send_command_help(self, command):
128128
if not await self.filter_commands([command]):
@@ -285,7 +285,7 @@ async def changelog(self, ctx, version: str.lower = ""):
285285
)
286286

287287
try:
288-
paginator = PaginatorSession(ctx, *changelog.embeds)
288+
paginator = EmbedPaginatorSession(ctx, *changelog.embeds)
289289
paginator.current = index
290290
await paginator.run()
291291
except asyncio.CancelledError:
@@ -358,7 +358,7 @@ async def sponsors(self, ctx):
358358

359359
random.shuffle(embeds)
360360

361-
session = PaginatorSession(ctx, *embeds)
361+
session = EmbedPaginatorSession(ctx, *embeds)
362362
await session.run()
363363

364364
@commands.group(invoke_without_command=True)
@@ -762,7 +762,7 @@ async def config_options(self, ctx):
762762
)
763763
embeds.append(embed)
764764

765-
session = PaginatorSession(ctx, *embeds)
765+
session = EmbedPaginatorSession(ctx, *embeds)
766766
await session.run()
767767

768768
@config.command(name="set", aliases=["add"])
@@ -926,7 +926,7 @@ def fmt(val):
926926
embed.set_thumbnail(url=fmt(info["thumbnail"]))
927927
embeds += [embed]
928928

929-
paginator = PaginatorSession(ctx, *embeds)
929+
paginator = EmbedPaginatorSession(ctx, *embeds)
930930
paginator.current = index
931931
await paginator.run()
932932

@@ -1003,7 +1003,7 @@ async def alias(self, ctx, *, name: str.lower = None):
10031003
embed.set_author(name="Command Aliases", icon_url=ctx.guild.icon_url)
10041004
embeds.append(embed)
10051005

1006-
session = PaginatorSession(ctx, *embeds)
1006+
session = EmbedPaginatorSession(ctx, *embeds)
10071007
await session.run()
10081008

10091009
@alias.command(name="raw")
@@ -1500,8 +1500,8 @@ async def permissions_get(
15001500
for perm_level in PermissionLevel:
15011501
embeds.append(self._get_perm(ctx, perm_level.name, "level"))
15021502

1503-
p_session = PaginatorSession(ctx, *embeds)
1504-
return await p_session.run()
1503+
session = EmbedPaginatorSession(ctx, *embeds)
1504+
return await session.run()
15051505

15061506
@commands.group(invoke_without_command=True)
15071507
@checks.has_permissions(PermissionLevel.OWNER)

0 commit comments

Comments
 (0)