From 7af6b6f52e1dff19e04bb106f27f0f2409788e10 Mon Sep 17 00:00:00 2001 From: Den4200 Date: Wed, 1 Jul 2020 00:37:38 +0000 Subject: Ensure slowmode delay is between 0 and 21600 seconds before setting it --- bot/cogs/slowmode.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bot/cogs/slowmode.py b/bot/cogs/slowmode.py index bab6eccd0..4a10d3fac 100644 --- a/bot/cogs/slowmode.py +++ b/bot/cogs/slowmode.py @@ -26,10 +26,16 @@ class Slowmode(Cog): @with_role(*MODERATION_ROLES) async def set_slowmode(self, ctx: Context, channel: TextChannel, seconds: int) -> None: """Set the slowmode delay for a given text channel.""" - await channel.edit(slowmode_delay=seconds) - await ctx.send( - f'{Emojis.check_mark} The slowmode delay for {channel.mention} is now {seconds} seconds.' - ) + if 0 <= seconds <= 21600: + await channel.edit(slowmode_delay=seconds) + await ctx.send( + f'{Emojis.check_mark} The slowmode delay for {channel.mention} is now {seconds} seconds.' + ) + + else: + await ctx.send( + f'{Emojis.cross_mark} The slowmode delay must be between 0 and 21600 seconds.' + ) def setup(bot: Bot) -> None: -- cgit v1.2.3