aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Boris Muratov <[email protected]>2022-04-22 01:31:57 +0300
committerGravatar GitHub <[email protected]>2022-04-22 01:31:57 +0300
commit8b8722b5a39649579b82766a39ec50b5c29c973f (patch)
tree5df941ef1cb4e925741f051dbaba94e8ec9557ea
parentMerge pull request #2143 from python-discord/bump-bot-core (diff)
parentMerge branch 'main' into slowmode/add-better-thread-support (diff)
Merge pull request #2133 from python-discord/slowmode/add-better-thread-support
Add discord.Thread to slowmode cog channel converters
-rw-r--r--bot/exts/moderation/slowmode.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/bot/exts/moderation/slowmode.py b/bot/exts/moderation/slowmode.py
index 92d984d32..c43ae8b0c 100644
--- a/bot/exts/moderation/slowmode.py
+++ b/bot/exts/moderation/slowmode.py
@@ -1,7 +1,7 @@
from typing import Literal, Optional, Union
from dateutil.relativedelta import relativedelta
-from discord import TextChannel
+from discord import TextChannel, Thread
from discord.ext.commands import Cog, Context, group, has_any_role
from bot.bot import Bot
@@ -20,6 +20,8 @@ COMMONLY_SLOWMODED_CHANNELS = {
Channels.off_topic_0: "ot0",
}
+MessageHolder = Optional[Union[TextChannel, Thread]]
+
class Slowmode(Cog):
"""Commands for getting and setting slowmode delays of text channels."""
@@ -33,7 +35,7 @@ class Slowmode(Cog):
await ctx.send_help(ctx.command)
@slowmode_group.command(name='get', aliases=['g'])
- async def get_slowmode(self, ctx: Context, channel: Optional[TextChannel]) -> None:
+ async def get_slowmode(self, ctx: Context, channel: MessageHolder) -> None:
"""Get the slowmode delay for a text channel."""
# Use the channel this command was invoked in if one was not given
if channel is None:
@@ -47,7 +49,7 @@ class Slowmode(Cog):
async def set_slowmode(
self,
ctx: Context,
- channel: Optional[TextChannel],
+ channel: MessageHolder,
delay: Union[DurationDelta, Literal["0s", "0seconds"]],
) -> None:
"""Set the slowmode delay for a text channel."""
@@ -87,7 +89,7 @@ class Slowmode(Cog):
)
@slowmode_group.command(name='reset', aliases=['r'])
- async def reset_slowmode(self, ctx: Context, channel: Optional[TextChannel]) -> None:
+ async def reset_slowmode(self, ctx: Context, channel: MessageHolder) -> None:
"""Reset the slowmode delay for a text channel to 0 seconds."""
await self.set_slowmode(ctx, channel, relativedelta(seconds=0))