diff --git a/obsbot/cogs/public/admin.py b/obsbot/cogs/public/admin.py index 5fb7263..f5425f0 100644 --- a/obsbot/cogs/public/admin.py +++ b/obsbot/cogs/public/admin.py @@ -18,6 +18,7 @@ def __init__(self, bot): ('.status', 'prints the bot\'s current status'), ('.setgame', 'Set the bot\'s "Playing ..." status'), ('.setsong', 'Set the bot\'s "Listening to ..." status'), + ('.slow', 'Set the current channel\'s Slowmode setting (0-21600 seconds)'), ] } self.restricted = set() @@ -102,6 +103,26 @@ def add_help_section(self, section_name, command_list, restricted=False): if restricted: self.restricted.add(section_name) + @command() + async def slow(self, ctx: Context, seconds: int = 0): + if not self.bot.is_admin(ctx.author): + return + + # Clamp to the min value of 0 seconds (disabled, no delay) + if seconds < 0: + seconds = 0 + + # Clamp to the max value of 21600 seconds (6 hours) + if seconds > 21600: + seconds = 21600 + + if seconds == 0: + await ctx.send('Slowmode has been disabled in this channel.') + elif seconds > 0: + await ctx.send(f'Slowmode has been enabled in this channel with a {seconds} second delay.') + + await ctx.channel.edit(slowmode_delay=seconds) + def setup(bot): bot.add_cog(Admin(bot)) diff --git a/obsbot/main.py b/obsbot/main.py index 180bcb3..6b66638 100644 --- a/obsbot/main.py +++ b/obsbot/main.py @@ -99,6 +99,8 @@ async def on_command_error(self, context, exception): return elif isinstance(exception, commands.errors.MissingRequiredArgument): return + elif isinstance(exception, commands.errors.BadArgument): + return raise exception async def close(self):