Skip to content

Commit

Permalink
cogs.admin: Add slowmode command
Browse files Browse the repository at this point in the history
Add the ability to edit a channel's slowmode delay.
  • Loading branch information
RytoEX committed Sep 8, 2021
1 parent 6d6e3de commit cf05b04
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions obsbot/cogs/public/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -102,6 +103,25 @@ 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(f"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))

0 comments on commit cf05b04

Please sign in to comment.