mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
parent
1581604f71
commit
aac9369f3f
@ -12,6 +12,7 @@ from .kickban import KickBanMixin
|
|||||||
from .movetocore import MoveToCore
|
from .movetocore import MoveToCore
|
||||||
from .mutes import MuteMixin
|
from .mutes import MuteMixin
|
||||||
from .names import ModInfo
|
from .names import ModInfo
|
||||||
|
from .slowmode import Slowmode
|
||||||
from .settings import ModSettings
|
from .settings import ModSettings
|
||||||
|
|
||||||
_ = T_ = Translator("Mod", __file__)
|
_ = T_ = Translator("Mod", __file__)
|
||||||
@ -36,6 +37,7 @@ class Mod(
|
|||||||
MoveToCore,
|
MoveToCore,
|
||||||
MuteMixin,
|
MuteMixin,
|
||||||
ModInfo,
|
ModInfo,
|
||||||
|
Slowmode,
|
||||||
commands.Cog,
|
commands.Cog,
|
||||||
metaclass=CompositeMetaClass,
|
metaclass=CompositeMetaClass,
|
||||||
):
|
):
|
||||||
|
|||||||
41
redbot/cogs/mod/slowmode.py
Normal file
41
redbot/cogs/mod/slowmode.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import re
|
||||||
|
from .abc import MixinMeta
|
||||||
|
from datetime import timedelta
|
||||||
|
from redbot.core import commands, i18n, checks
|
||||||
|
from redbot.core.utils.chat_formatting import humanize_timedelta
|
||||||
|
|
||||||
|
_ = i18n.Translator("Mod", __file__)
|
||||||
|
|
||||||
|
|
||||||
|
class Slowmode(MixinMeta):
|
||||||
|
"""
|
||||||
|
Commands regarding channel slowmode management.
|
||||||
|
"""
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
@commands.guild_only()
|
||||||
|
@commands.bot_has_permissions(manage_channels=True)
|
||||||
|
@checks.admin_or_permissions(manage_channels=True)
|
||||||
|
async def slowmode(
|
||||||
|
self,
|
||||||
|
ctx,
|
||||||
|
*,
|
||||||
|
interval: commands.TimedeltaConverter(
|
||||||
|
minimum=timedelta(seconds=0), maximum=timedelta(hours=6)
|
||||||
|
) = timedelta(seconds=0),
|
||||||
|
):
|
||||||
|
"""Changes channel's slowmode setting.
|
||||||
|
|
||||||
|
Interval can be anything from 0 seconds to 6 hours.
|
||||||
|
Use without parameters to disable.
|
||||||
|
"""
|
||||||
|
seconds = interval.total_seconds()
|
||||||
|
await ctx.channel.edit(slowmode_delay=seconds)
|
||||||
|
if seconds > 0:
|
||||||
|
await ctx.send(
|
||||||
|
_("Slowmode interval is now {interval}.").format(
|
||||||
|
interval=humanize_timedelta(timedelta=interval)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
await ctx.send(_("Slowmode has been disabled."))
|
||||||
Loading…
x
Reference in New Issue
Block a user