From abcf1c7c9fae02d86f605968f9ba0540cda6db82 Mon Sep 17 00:00:00 2001 From: Piplup <100526773+piplup55@users.noreply.github.com> Date: Wed, 15 May 2024 16:21:21 +0100 Subject: [PATCH] Better Slowmode command (#95) * Update mod.py * Handle optional slowmode parameter correctly --------- Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com> --- robocop_ng/cogs/mod.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/robocop_ng/cogs/mod.py b/robocop_ng/cogs/mod.py index 9aac04a..8792391 100644 --- a/robocop_ng/cogs/mod.py +++ b/robocop_ng/cogs/mod.py @@ -3,7 +3,7 @@ from typing import Optional import discord from discord.ext import commands -from discord.ext.commands import Cog +from discord.ext.commands import Cog, Context from robocop_ng.helpers.checks import check_if_staff, check_if_bot_manager from robocop_ng.helpers.restrictions import add_restriction, remove_restriction @@ -914,11 +914,18 @@ class Mod(Cog): @commands.guild_only() @commands.check(check_if_staff) @commands.command(aliases=["slow"]) - async def slowmode(self, ctx, seconds: int): + async def slowmode( + self, ctx: Context, seconds: int, channel: Optional[discord.TextChannel] = None + ): + if channel is None: + channel = ctx.channel + if seconds > 21600 or seconds < 0: return await ctx.send("Seconds can't be above '21600' or less then '0'") - await ctx.channel.edit(slowmode_delay=seconds) + await channel.edit( + slowmode_delay=seconds, reason=f"{str(ctx.author)} set the slowmode" + ) await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")