diff --git a/cogs/general/serverinfo.py b/cogs/general/serverinfo.py index 1c499c9..f0cf8a6 100644 --- a/cogs/general/serverinfo.py +++ b/cogs/general/serverinfo.py @@ -47,7 +47,7 @@ class ServerInfo(commands.Cog, name="serverinfo"): name=f"Roles ({len(context.guild.roles)})", value=roles ) - embed.set_footer(text=f"Created at: {context.guild.created_at}") + embed.set_footer(text=f"Created at: {context.guild.created_at.strftime('%m/%d/%Y')}") if getattr(context, "interaction", None): await context.interaction.response.send_message(embed=embed, ephemeral=True) @@ -55,5 +55,4 @@ class ServerInfo(commands.Cog, name="serverinfo"): await context.send(embed=embed) async def setup(bot) -> None: - await bot.add_cog(ServerInfo(bot)) - + await bot.add_cog(ServerInfo(bot)) \ No newline at end of file diff --git a/cogs/moderation/archive.py b/cogs/moderation/archive.py index fea1323..62de5da 100644 --- a/cogs/moderation/archive.py +++ b/cogs/moderation/archive.py @@ -1,11 +1,3 @@ -""" -Copyright © Krypton 2019-Present - https://github.com/kkrypt0nn (https://krypton.ninja) -Description: -🐍 A simple template to start to code your own and personalized Discord bot in Python - -Version: 6.4.0 -""" - import os from datetime import datetime import discord @@ -34,28 +26,35 @@ class Archive(commands.Cog, name="archive"): :param limit: The limit of messages that should be archived. Default is 10. """ log_file = f"{context.channel.id}.log" + + messages = [] + async for message in context.channel.history( + limit=limit, before=context.message + ): + attachments = [] + for attachment in message.attachments: + attachments.append(attachment.url) + attachments_text = ( + f"[Attached File{'s' if len(attachments) >= 2 else ''}: {', '.join(attachments)}]" + if len(attachments) >= 1 + else "" + ) + + message_line = f"{message.created_at.strftime('%d.%m.%Y %H:%M:%S')} {message.author} {message.id}: {message.clean_content} {attachments_text}\n" + messages.append(message_line) + with open(log_file, "w", encoding="UTF-8") as f: f.write( f'Archived messages from: #{context.channel} ({context.channel.id}) in the guild "{context.guild}" ({context.guild.id}) at {datetime.now().strftime("%d.%m.%Y %H:%M:%S")}\n' ) - async for message in context.channel.history( - limit=limit, before=context.message - ): - attachments = [] - for attachment in message.attachments: - attachments.append(attachment.url) - attachments_text = ( - f"[Attached File{'s' if len(attachments) >= 2 else ''}: {', '.join(attachments)}]" - if len(attachments) >= 1 - else "" - ) - f.write( - f"{message.created_at.strftime('%d.%m.%Y %H:%M:%S')} {message.author} {message.id}: {message.clean_content} {attachments_text}\n" - ) + + for message_line in reversed(messages): + f.write(message_line) + f = discord.File(log_file) await context.send(file=f) os.remove(log_file) async def setup(bot) -> None: - await bot.add_cog(Archive(bot)) + await bot.add_cog(Archive(bot)) \ No newline at end of file