From 0ee61c808470373beab82e6fc3a0a258d6a01e39 Mon Sep 17 00:00:00 2001 From: Myned Date: Wed, 4 Oct 2017 16:29:13 -0400 Subject: [PATCH] Added prune all user command --- src/main/cogs/management.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/main/cogs/management.py diff --git a/src/main/cogs/management.py b/src/main/cogs/management.py new file mode 100644 index 0000000..7115451 --- /dev/null +++ b/src/main/cogs/management.py @@ -0,0 +1,29 @@ +import asyncio +import discord +import traceback +import discord +from discord.ext import commands +from misc import checks +from misc import exceptions as exc + +class Administration: + + def __init__(self, bot): + self.bot = bot + + @commands.command(name='prunealluser') + @commands.is_owner() + async def prune_all_user(self, ctx, uid): + channels = ctx.message.guild.channels + member = ctx.message.guild.get_member(uid) + history = {} + c = 0 + for channel in channels: + history[channel.id] = await channel.history().flatten() + print('Added: ' + channel.id) + for channel, messages in history.items(): + for message in messages: + if message.author is member: + await message.delete() + c += 1 + await ctx.send('✅ `' + c + '` **messages deleted from the server.**')