purge: add

This commit is contained in:
Ave Ozkal 2018-12-23 23:59:08 +03:00
parent 15bb78a252
commit 93a5354761
No known key found for this signature in database
GPG key ID: 09356ABAA42C842B
2 changed files with 21 additions and 2 deletions

View file

@ -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

View file

@ -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))