Files
Discord-Radio-Bot/modules/ClearChannelMessages/cog.py
Logan Cusano 35e19ee83f //WIP v3
Clear Messages Changes
- New approach
2022-04-09 21:39:44 -04:00

31 lines
856 B
Python

import logging
from discord.ext import commands
import asyncio
LOGGER = logging.getLogger("Discord_Radio_Bot.LinkCop")
class ClearMessages(commands.Cog):
def __init__(self, bot):
self.Bot = bot
@commands.command()
async def clear(self, ctx, amount=0):
member = ctx.author.display_name
LOGGER.info(f"Clear {amount} messages requested by {member}")
authors = {}
async for message in ctx.channel.history(limit=amount + 1):
if message.author not in authors:
authors[message.author] = 1
else:
authors[message.author] += 1
await message.delete()
msg = "\n".join([f"{author}:{amount}" for author, amount in authors.items()])
await ctx.channel.send(msg)
def setup(bot: commands.Bot):
bot.add_cog(ClearMessages(bot))