mahtoid / DiscordChatExporterPy

A simple Discord chat exporter for Python Discord bots.
GNU General Public License v3.0
209 stars 75 forks source link

Error with quick_export and export #94

Closed Chucky5063 closed 10 months ago

Chucky5063 commented 1 year ago

DiscordChatExporterPy Version

2.6.1

Discord Version

pycord=2.4.1

Bug Description

When executing either of the two methods shown on the guide I receive the same result. I am a novice programmer and may be at fault for this but thought reaching out wouldn't hurt. I am on the latest python 3.11.5. Thank you and I like the project!

@commands.slash_command(name='test', description='test', guild_ids=config.devServerID)
  async def save(self, ctx: commands.Context):
    await chat_exporter.quick_export(ctx.channel)

or

@commands.slash_command(name='test', description='test', guild_ids=config.devServerID)
async def save(self, ctx: commands.Context, limit: int = 100, tz_info: str = "UTC", military_time: bool = True):
      transcript = await chat_exporter.export(
          ctx.channel,
          limit=limit,
          tz_info=tz_info,
          military_time=military_time,
          bot=self.bot,
      )

      if transcript is None:
          return

      transcript_file = discord.File(
          io.BytesIO(transcript.encode()),
          filename=f"transcript-{ctx.channel.name}.html",
      )

      await ctx.send(file=transcript_file)

I also tried with a vanilla project with just the chat exporter

import discord
import chat_exporter
from discord.ext import commands

intents = discord.Intents.default()
intents.members = True
intents.message_content = True

bot = commands.Bot(command_prefix="!", intents=intents)

...

@bot.command()
async def save(ctx: commands.Context):
    await chat_exporter.quick_export(ctx.channel)

try:
    bot.run()
except Exception as e:
    print(f"ERROR: {e}")

image

Bug Traceback

Traceback (most recent call last): File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\chat_exporter\construct\transcript.py", line 171, in export return await super().build_transcript() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\chat_exporter\construct\transcript.py", line 56, in build_transcript message_html, meta_data = await gather_messages( File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\chat_exporter\construct\message.py", line 455, in gather_messages content_html, meta_data = await MessageConstruct( ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\chat_exporter\construct\message.py", line 92, in construct_message await self.build_message() File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\chat_exporter\construct\message.py", line 96, in build_message await self.build_content() File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\chat_exporter\construct\message.py", line 152, in build_content self.message.content = await fill_out(self.guild, message_content, [ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ v = await ParseMention(v, guild).flow() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\chat_exporter\parse\mention.py", line 54, in flow await self.time_mention() File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\chat_exporter\parse\mention.py", line 153, in time_mention time = datetime.datetime.fromtimestamp(int(match.group(1)), timezone) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OSError: [Errno 22] Invalid argument Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Additional Information

No response

mahtoid commented 1 year ago

In the chat you are attempting to export, there seems to be a malformed datetime string.

A standard string should look something like <t:1543392060> - is there any way you can figure out the broken one, so I can work in a solution?

Chucky5063 commented 1 year ago

There was a member attempting to format a timestamp as . However, that is not a valid unix time which was what flagged the error. Thank you for pointing that out!

mahtoid commented 1 year ago

Thank you for that, I have added this in to the list to deal with in the next version.

However, unknown when that will currently be. I'm currently working on getting another project to Version 2 which should be released within the next week or two. After that, I should be focused on working on chat-exporter v2.7.

mahtoid commented 10 months ago

This has been solved in the next version coming out soon, terrible sorry for the delay.