diff options
| author | 2020-07-01 00:37:38 +0000 | |
|---|---|---|
| committer | 2020-07-01 00:37:38 +0000 | |
| commit | 7af6b6f52e1dff19e04bb106f27f0f2409788e10 (patch) | |
| tree | 77f215f35fff2605b94bc15f8db0981f56eb99ed | |
| parent | Implement the set_slowmode function (diff) | |
Ensure slowmode delay is between 0 and 21600 seconds before setting it
| -rw-r--r-- | bot/cogs/slowmode.py | 14 |
1 files 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: |