From 59f0375ad58985bee983ddc33954f8e555cdae1e Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Fri, 15 Dec 2023 22:28:42 -0500 Subject: [PATCH] fix(moderation): limited pagesize to 20 --- moderation/moderation.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/moderation/moderation.py b/moderation/moderation.py index 7b57825..7c7c0e5 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -911,7 +911,7 @@ class Moderation(commands.Cog): await self.log(interaction, moderation_id) @app_commands.command(name="history") - async def history(self, interaction: discord.Interaction, target: discord.User = None, moderator: discord.User = None, pagesize: app_commands.Range[int, 1, 25] = None, page: int = 1, ephemeral: bool = None, inline: bool = None, export: bool = False): + async def history(self, interaction: discord.Interaction, target: discord.User = None, moderator: discord.User = None, pagesize: app_commands.Range[int, 1, 20] = None, page: int = 1, ephemeral: bool = None, inline: bool = None, export: bool = False): """List previous infractions. Parameters @@ -1382,6 +1382,12 @@ class Moderation(commands.Cog): @moderationset_history.command(name='pagesize') async def moderationset_history_user_pagesize(self, ctx: commands.Context, pagesize: int): """Set the amount of cases to display per page.""" + if pagesize > 20: + await ctx.send("Pagesize cannot be greater than 20!") + return + if pagesize < 1: + await ctx.send("Pagesize cannot be less than 1!") + return await self.config.user(ctx.author).history_pagesize.set(pagesize) await ctx.send(f"Pagesize set to {await self.config.user(ctx.author).history_pagesize()}") @@ -1398,6 +1404,12 @@ class Moderation(commands.Cog): @moderationset_history_inline.command(name='pagesize') async def moderationset_history_user_inline_pagesize(self, ctx: commands.Context, pagesize: int): """Set the amount of cases to display per page.""" + if pagesize > 20: + await ctx.send("Pagesize cannot be greater than 20!") + return + if pagesize < 1: + await ctx.send("Pagesize cannot be less than 1!") + return await self.config.user(ctx.author).history_inline_pagesize.set(pagesize) await ctx.send(f"Inline pagesize set to {await self.config.user(ctx.author).history_inline_pagesize()}") @@ -1417,6 +1429,12 @@ class Moderation(commands.Cog): @checks.admin() async def moderationset_history_guild_pagesize(self, ctx: commands.Context, pagesize: int): """Set the amount of cases to display per page.""" + if pagesize > 20: + await ctx.send("Pagesize cannot be greater than 20!") + return + if pagesize < 1: + await ctx.send("Pagesize cannot be less than 1!") + return await self.config.guild(ctx.guild).history_pagesize.set(pagesize) await ctx.send(f"Pagesize set to {await self.config.guild(ctx.guild).history_pagesize()}") @@ -1436,6 +1454,12 @@ class Moderation(commands.Cog): @checks.admin() async def moderationset_history_guild_inline_pagesize(self, ctx: commands.Context, pagesize: int): """Set the amount of cases to display per page.""" + if pagesize > 20: + await ctx.send("Pagesize cannot be greater than 20!") + return + if pagesize < 1: + await ctx.send("Pagesize cannot be less than 1!") + return await self.config.guild(ctx.guild).history_inline_pagesize.set(pagesize) await ctx.send(f"Inline pagesize set to {await self.config.guild(ctx.guild).history_inline_pagesize()}")