Skip to content

Commit cf05b04

Browse files
committed
cogs.admin: Add slowmode command
Add the ability to edit a channel's slowmode delay.
1 parent 6d6e3de commit cf05b04

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

obsbot/cogs/public/admin.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def __init__(self, bot):
1818
('.status', 'prints the bot\'s current status'),
1919
('.setgame', 'Set the bot\'s "Playing ..." status'),
2020
('.setsong', 'Set the bot\'s "Listening to ..." status'),
21+
('.slow', 'Set the current channel\'s Slowmode setting (0-21600 seconds)'),
2122
]
2223
}
2324
self.restricted = set()
@@ -102,6 +103,25 @@ def add_help_section(self, section_name, command_list, restricted=False):
102103
if restricted:
103104
self.restricted.add(section_name)
104105

106+
@command()
107+
async def slow(self, ctx: Context, seconds: int = 0):
108+
if not self.bot.is_admin(ctx.author):
109+
return
110+
111+
# Clamp to the min value of 0 seconds (disabled, no delay)
112+
if seconds < 0:
113+
seconds = 0
114+
115+
# Clamp to the max value of 21600 seconds (6 hours)
116+
if seconds > 21600:
117+
seconds = 21600
118+
119+
if seconds == 0:
120+
await ctx.send(f"Slowmode has been disabled in this channel.")
121+
elif seconds > 0:
122+
await ctx.send(f"Slowmode has been enabled in this channel with a {seconds} second delay.")
123+
124+
await ctx.channel.edit(slowmode_delay=seconds)
105125

106126
def setup(bot):
107127
bot.add_cog(Admin(bot))

0 commit comments

Comments
 (0)