fix(moderation): limited pagesize to 20
Some checks failed
Pylint / Pylint (3.10) (push) Failing after 47s

This commit is contained in:
Seaswimmer 2023-12-15 22:28:42 -05:00
parent f12f4b5406
commit 59f0375ad5
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE

View file

@ -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()}")