From 93a5354761ddfbdfad626b2968ff424963800ed2 Mon Sep 17 00:00:00 2001 From: Ave Ozkal Date: Sun, 23 Dec 2018 23:59:08 +0300 Subject: [PATCH] purge: add --- README.md | 4 ++-- cogs/mod.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b8a19a..9cba824 100755 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Based on https://gitlab.com/ao/dpybotbase - [x] Moderation: playing - [x] Moderation: botnickname - [x] Moderation: nickname -- [ ] Moderation: clear/purge +- [x] Moderation: clear/purge - [ ] Moderation: restrictions (people who leave with muted role will get muted role on join) - [ ] Warns: warn - [ ] Warns: delwarnid-delwarn @@ -52,5 +52,5 @@ Main goal of this project is to get Robocop functionality done, secondary goal i - [ ] New moderation feature: User notes - [ ] New moderation feature: watch-unwatch (using log module from akbbot) - [ ] New moderation feature: timelock (channel lockdown with time) -- [ ] End of development: eval and sh might need to be removed at end of development +- [ ] End of development: eval, fetchlog and sh might need to be removed at end of development diff --git a/cogs/mod.py b/cogs/mod.py index 788a742..57c181c 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -260,6 +260,8 @@ class ModCog: else: await self.bot.change_presence(activity=None) + await ctx.send("Successfully set game.") + @commands.guild_only() @commands.check(check_if_staff) @commands.command(aliases=["setbotnick", "botnick", "robotnick"]) @@ -273,6 +275,8 @@ class ModCog: else: await ctx.guild.me.edit(nick=None, reason=str(ctx.author)) + await ctx.send("Successfully set nickname.") + @commands.guild_only() @commands.check(check_if_staff) @commands.command(aliases=["setnick", "nick"]) @@ -286,6 +290,21 @@ class ModCog: else: await target.edit(nick=None, reason=str(ctx.author)) + await ctx.send("Successfully set nickname.") + + @commands.guild_only() + @commands.check(check_if_staff) + @commands.command(aliases=["clear"]) + async def purge(self, ctx, limit: int, channel: discord.TextChannel = None): + """Clears a given number of messages. Staff only.""" + log_channel = self.bot.get_channel(config.log_channel) + if not channel: + channel = ctx.channel + await channel.purge(limit=limit) + msg = f"🗑 **Cleared**: {ctx.author.mention} cleared {limit} "\ + f"messages in {channel.mention}." + await log_channel.send(msg) + def setup(bot): bot.add_cog(ModCog(bot))