aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2022-04-21 22:12:16 +0100
committerGravatar GitHub <[email protected]>2022-04-21 22:12:16 +0100
commitb5face45d75d0605564167a3b36d6c1151b42bae (patch)
treee6cab8113ef2e898a2da6bd217fd334a24c86fac
parentMerge pull request #2138 from python-discord/Use-bot-core-extensions (diff)
parentMerge branch 'main' into 0s-slowmode (diff)
Merge pull request #2134 from novialriptide/0s-slowmode
Added an option to use 0s as an argument
-rw-r--r--bot/exts/moderation/slowmode.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/bot/exts/moderation/slowmode.py b/bot/exts/moderation/slowmode.py
index 1be568a56..92d984d32 100644
--- a/bot/exts/moderation/slowmode.py
+++ b/bot/exts/moderation/slowmode.py
@@ -1,4 +1,4 @@
-from typing import Optional
+from typing import Literal, Optional, Union
from dateutil.relativedelta import relativedelta
from discord import TextChannel
@@ -44,7 +44,12 @@ class Slowmode(Cog):
await ctx.send(f'The slowmode delay for {channel.mention} is {humanized_delay}.')
@slowmode_group.command(name='set', aliases=['s'])
- async def set_slowmode(self, ctx: Context, channel: Optional[TextChannel], delay: DurationDelta) -> None:
+ async def set_slowmode(
+ self,
+ ctx: Context,
+ channel: Optional[TextChannel],
+ delay: Union[DurationDelta, Literal["0s", "0seconds"]],
+ ) -> None:
"""Set the slowmode delay for a text channel."""
# Use the channel this command was invoked in if one was not given
if channel is None:
@@ -52,8 +57,10 @@ class Slowmode(Cog):
# Convert `dateutil.relativedelta.relativedelta` to `datetime.timedelta`
# Must do this to get the delta in a particular unit of time
- slowmode_delay = time.relativedelta_to_timedelta(delay).total_seconds()
+ if isinstance(delay, str):
+ delay = relativedelta(seconds=0)
+ slowmode_delay = time.relativedelta_to_timedelta(delay).total_seconds()
humanized_delay = time.humanize_delta(delay)
# Ensure the delay is within discord's limits