Better Slowmode command (#95)

* Update mod.py

* Handle optional slowmode parameter correctly

---------

Co-authored-by: TSR Berry <20988865+TSRBerry@users.noreply.github.com>
This commit is contained in:
Piplup 2024-05-15 16:21:21 +01:00 committed by GitHub
parent 2daca3a4b7
commit abcf1c7c9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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!")