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:
parent
2daca3a4b7
commit
abcf1c7c9f
1 changed files with 10 additions and 3 deletions
|
@ -3,7 +3,7 @@ from typing import Optional
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
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.checks import check_if_staff, check_if_bot_manager
|
||||||
from robocop_ng.helpers.restrictions import add_restriction, remove_restriction
|
from robocop_ng.helpers.restrictions import add_restriction, remove_restriction
|
||||||
|
@ -914,11 +914,18 @@ class Mod(Cog):
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@commands.check(check_if_staff)
|
@commands.check(check_if_staff)
|
||||||
@commands.command(aliases=["slow"])
|
@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:
|
if seconds > 21600 or seconds < 0:
|
||||||
return await ctx.send("Seconds can't be above '21600' or less then '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!")
|
await ctx.send(f"Set the slowmode delay in this channel to {seconds} seconds!")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue