mahtoid / DiscordChatExporterPy

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

Channel archiving error with deleted message #123

Open Cody140 opened 1 month ago

Cody140 commented 1 month ago

DiscordChatExporterPy Version

2.8.0

Discord Version

2.4.0

Bug Description

if you archive a channel that has a reply to a deleted message, an error of trying to fetch the message appears my channel archiving code

    transcript = await chat_exporter.export(interaction.channel)
    if transcript is None:
        return

    encode_async = functools.partial(io.BytesIO, transcript.encode())

    transcript_file = discord.File(
        await interaction.client.loop.run_in_executor(None,encode_async),
        filename=f"transcript-{interaction.channel.name}.html",
    )
    archive_channel = interaction.guild.get_channel(config['tickets']['archive_id'])
    msg = await archive_channel.send(file=transcript_file)

Bug Traceback

Traceback (most recent call last): File "C:\Users\codyl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\chat_exporter\construct\transcript.py", line 187, in export return await super().build_transcript() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\codyl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\chat_exporter\construct\transcript.py", line 59, in build_transcript message_html, meta_data = await gather_messages( ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\codyl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\chat_exporter\construct\message.py", line 484, in gather_messages content_html, meta_data = await MessageConstruct( ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\codyl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\chat_exporter\construct\message.py", line 100, in construct_message await self.build_message() File "C:\Users\codyl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\chat_exporter\construct\message.py", line 105, in build_message await self.build_reference() File "C:\Users\codyl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\chat_exporter\construct\message.py", line 174, in build_reference message: discord.Message = await self.message.channel.fetch_message(self.message.reference.message_id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\codyl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\abc.py", line 1684, in fetch_message data = await self._state.http.get_message(channel.id, id) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\codyl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\discord\http.py", line 754, in request raise NotFound(response, data) discord.errors.NotFound: 404 Not Found (error code: 10008): Unknown Message Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Additional Information

image

doluk commented 2 days ago

@Cody140 I am unable to reproduce the error with version 2.8.0 with chat-exporter. Can you please provide a minimal example that reproduces this issue?