V3_GQRX_Improvements #11

Merged
logan merged 36 commits from V3_GQRX_Improvements into master 2022-04-16 20:52:44 -04:00
Showing only changes of commit 8d090c5c67 - Show all commits

View File

@@ -1,6 +1,5 @@
import logging
from discord.ext import commands
import asyncio
LOGGER = logging.getLogger("Discord_Radio_Bot.LinkCop")
@@ -12,17 +11,24 @@ class ClearMessages(commands.Cog):
@commands.command()
async def clear(self, ctx, amount=0):
member = ctx.author.display_name
mtn_member = f"<@{member}>"
LOGGER.info(f"Clear {amount} messages requested by {member}")
authors = {}
async for message in ctx.channel.history(limit=amount + 1):
authors = {}
async for message in ctx.channel.history(limit=amount):
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()])
msg = f"{mtn_member}, I deleted {sum(authors.values())} messages\n"
LOGGER.debug(f"Deleted {sum(authors.values())} messages from {ctx.message.channel}")
for author in authors.keys():
msg += f"\t{author}: {authors[author]}"
LOGGER.debug(f"Deleted {authors[author]} messages from {author}")
await ctx.channel.send(msg)