Giter Site home page Giter Site logo

mahtoid / discordchatexporterpy Goto Github PK

View Code? Open in Web Editor NEW
191.0 191.0 70.0 1.12 MB

A simple Discord chat exporter for Python Discord bots.

License: GNU General Public License v3.0

Python 60.76% HTML 39.24%
discord discordpy enhanced-dpy export pycord python

discordchatexporterpy's Introduction

Version Language Forks Stargazers Issues GPL License

DiscordChatExporterPy

Export Discord chats with your discord.py (or fork) bots!
Join Discord ยท Report Bug ยท Request Feature


Installation

To install the library to your virtual environment, for bot usage, run the command:

pip install chat-exporter

To clone the repository locally, run the command:

git clone https://github.com/mahtoid/DiscordChatExporterPy

(back to top)


Usage

There are currently 3 methods (functions) to chat-exporter which you can use to export your chat.
Expand the blocks below to learn the functions, arguments and usages.

Basic Usage

.quick_export() is the simplest way of using chat-exporter.

Using the quick_export function will gather the history of the channel you give, build the transcript then post the file and embed directly to the channel - returning a message object gathered from the message it posted.

This is mostly seen as a demo function, as opposed to a command you should actually use.

Required Argument(s):
channel: discord.TextChannel object, whether ctx.channel or any channel you gather.

Optional Argument(s):
bot: commands.Bot object to gather members who are no longer in your guild.

Return Argument:
discord.Message: The message quick_export will send, containing the embed and exported chat file.

Example:

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)

...
Customisable Usage

.export() is the most efficient and flexible method to export a chat using chat-exporter.

Using the export function will generate a transcript using the channel you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).

This would be the main function to use within chat-exporter.

Required Argument(s):
channel: discord.TextChannel object, whether ctx.channel or any channel you gather.

Optional Argument(s):
limit: Integer value to set the limit (amount of messages) the chat exporter gathers when grabbing the history (default=unlimited).
tz_info: String value of a TZ Database name to set a custom timezone for the exported messages (default=UTC).
guild: discord.Guild object which can be passed in to solve bugs for certain forks.
military_time: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format).
fancy_times: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day).
before: datetime.datetime object which allows to gather messages from before a certain date.
after: datetime.datetime object which allows to gather messages from after a certain date.
bot: commands.Bot object to gather members who are no longer in your guild.
attachment_handler: chat_exporter.AttachmentHandler object to export assets to in order to make them available after the channel got deleted.

Return Argument:
transcript: The HTML build-up for you to construct the HTML File with Discord.

Example:

import io

...

@bot.command()
async def save(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=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)
Raw Usage

.raw_export() is for the crazy people who like to do their own thing when using chat-exporter.

Using the raw_export function will generate a transcript using the list of messages you pass in, along with using any of the custom kwargs passed in to set limits, timezone, 24h formats and more (listed below).

This would be for people who want to filter what content to export.

Required Argument(s):
channel: discord.TextChannel object, whether ctx.channel or any channel you gather (this is just for padding the header).
messages: A list of Message objects which you wish to export to an HTML file.

Optional Argument(s):
tz_info: String value of a TZ Database name to set a custom timezone for the exported messages (default=UTC)
military_time: Boolean value to set a 24h format for times within your exported chat (default=False | 12h format)
fancy_times: Boolean value which toggles the 'fancy times' (Today|Yesterday|Day)
bot: commands.Bot object to gather members who are no longer in your guild. attachment_handler: chat_exporter.AttachmentHandler object to export assets to in order to make them available after the channel got deleted.

Return Argument:
transcript: The HTML build-up for you to construct the HTML File with Discord.

Example:

import io

...

@bot.command()
async def purge(ctx: commands.Context, tz_info: str, military_time: bool):
    deleted_messages = await ctx.channel.purge()

    transcript = await chat_exporter.raw_export(
        ctx.channel,
        messages=deleted_messages,
        tz_info=tz_info,
        military_time=military_time,
        bot=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)

(back to top)


Attachment Handler

Due to Discords newly introduced restrictions on to their CDN, we have introduced an Attachment Handler. This handler will assist you with circumventing the 'broken' and 'dead-assets' which arise when former attachments hosted by Discord reach their expiration date.

The AttachmentHandler serves as a template for you to implement your own asset handler. Below are two basic examples on how to use the AttachmentHandler. One using the example of storing files on a local webserver, with the other being an example of storing them on Discord (the latter merely just being an example, this will still obviously run in to the expiration issue).

If you do not specify an attachment handler, chat-exporter will continue to use the (proxy) URLs for the assets.

Concept

The concept of implementing such an AttachmentHandler is very easy. In the following a short general procedure is described to write your own AttachmentHandler fitting your storage solution. Here we will assume, that we store the attachments in a cloud storage.

  1. Subclassing Start by subclassing chat_exporter.AttachmentHandler and implement the __init__ method if needed. This should look something like this:
from chat_exporter import AttachmentHandler
from cloud_wrapper import CloudClient


class MyAttachmentHandler(AttachmentHandler):
    def __init__(self, *args, **kwargs):
        # Your initialization code here
        # in your case we just create the cloud client
        self.cloud_client = CloudClient()
  1. Overwrite process_asset The process_asset method is the method that is called for each asset in the chat. Here we have to implement the upload logic and the generation of the asset url from the uploaded asset.
import io
import aiohttp
from chat_exporter import AttachmentHandler
from cloud_wrapper import CloudClient
from discord import Attachment


class MyAttachmentHandler(AttachmentHandler):
    async def process_asset(self, attachment: Attachment):
        # Your upload logic here, in our example we just upload the asset to the cloud
        
        # first we need to authorize the client
        await self.cloud_client.authorize()
        
        # then we fetch the content of the attachment
        async with aiohttp.ClientSession() as session:
            async with session.get(attachment.url) as res:
                if res.status != 200:
                    res.raise_for_status()
                data = io.BytesIO(await res.read())
        data.seek(0)
        
        # and upload it to the cloud, back we get some sort of identifier for the uploaded file
        asset_id = await self.cloud_client.upload(data)
        
        # now we can generate the asset url from the identifier
        asset_url = await self.cloud_client.get_share_url(asset_id, shared_with="everyone")
        
        # and set the url attribute of the attachment to the generated url
        attachment.url = asset_url
        return attachment

Note

  1. The process_asset method should return the attachment object with the url attribute set to the generated url.
  2. The process_asset method should be an async method, as it is likely that you have to do some async operations like fetching the content of the attachment or uploading it to the cloud.
  3. You are free to add other methods in your class, and call them from process_asset if you need to do some operations before or after the upload of the asset. But the process_asset method is the only method that is called from chat-exporter.

Examples:

    AttachmentToLocalFileHostHandler

    Assuming you have a file server running, which serves the content of the folder /usr/share/assets/ under https://example.com/assets/, you can easily use the AttachmentToLocalFileHostHandler like this:

    import io
    import discord
    from discord.ext import commands
    import chat_exporter
    from chat_exporter import AttachmentToLocalFileHostHandler
    
    ...
    
    # Establish the file handler
    file_handler = AttachmentToLocalFileHostHandler(
        base_path="/usr/share/assets",
        url_base="https://example.com/assets/",
    )
    
    @bot.command()
    async def save(ctx: commands.Context):
        transcript = await chat_exporter.export(
            ctx.channel,
            attachment_handler=file_handler,
        )
    
        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)
    AttachmentToDiscordChannel

    Assuming you want to store your attachments in a discord channel, you can use the AttachmentToDiscordChannel. Please note that discord recent changes regarding content links will result in the attachments links being broken after 24 hours. While this is therefor not a recommended way to store your attachments, it should give you a good idea how to perform asynchronous storing of the attachments.

    import io
    import discord
    from discord.ext import commands
    import chat_exporter
    from chat_exporter import AttachmentToDiscordChannel
    
    ...
    
    # Establish the file handler
    channel_handler = AttachmentToDiscordChannel(
        channel=bot.get_channel(CHANNEL_ID),
    )
    
    @bot.command()
    async def save(ctx: commands.Context):
        transcript = await chat_exporter.export(
            ctx.channel,
            attachment_handler=channel_handler,
        )
    
        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)

(back to top)


Screenshots

General
    Discord
    Chat-Exporter

(back to top)


Additional Functions

Link Function Downloading exported chats can build up a bunch of unwanted files on your PC which can get annoying, additionally - not everyone wants to download content from Discord.

Due to these pain, and many requests - I have built a fancy PHP script which will show the transcript file within a browser.

    quick_link Similar in design to `.quick_export()` this is a bit of a demo function to produce a link and to give you an embed.

    Required Argument(s):
    channel: discord.TextChannel object, whether ctx.channel or any channel you gather.
    message: The Discord message containing the transcript file

    Return Argument:
    discord.Message: The message quick_link will send, containing the embed.

    Example:

    import chat_exporter
    
    ...
    
    @bot.command()
    async def save(ctx: commands.Context):
        message = await chat_exporter.quick_export(ctx.channel)
        await chat_exporter.quick_link(ctx.channel, message)
    link A simple function to return the link you will need to view the transcript online.

    Required Argument(s):
    message: The Discord message containing the transcript file

    Return Argument:
    link: The link to view the transcript file online

    Example:

    import io
    
    import chat_exporter
    
    ...
    
    @bot.command()
    async def save(ctx: commands.Context):
        transcript = await chat_exporter.export(ctx.channel)
        
        if transcript is None:
            return
    
        transcript_file = discord.File(
            io.BytesIO(transcript.encode()),
            filename=f"transcript-{ctx.channel.name}.html",
        )
    
        message = await ctx.send(file=transcript_file)
        link = await chat_exporter.link(message)
    
        await ctx.send("Click this link to view the transcript online: " + link)

Please note that the PHP script does NOT store any information.
It simply makes a request to the given URL and echos (prints) the content for you to be able to view it.


Attributions

This project borrows CSS and HTML code from Tyrrrz's C# DiscordChatExporter repository.

(back to top)

discordchatexporterpy's People

Contributors

doluk avatar kapppa avatar mahtoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

discordchatexporterpy's Issues

Pin Add messages do not export as expected

DiscordChatExporterPy Version

2.2.1

Discord Version

Discord.py 2.0.0a4318+g823d650e (Most recent commit at time of writing)

Bug Description

When creating a transcript with export() or quick_export() (I haven't tested with raw_export()), any messages to show a pin being added will be shown as an empty message from the user pinning the message, replying to the message they pinned, instead of a message stating "USER pinned a message to this channel. See all pinned messages."

Bug Traceback

No console output.

Additional Information

image
image

AttributeError: 'Member' object has no attribute 'display_avatar'

Traceback (most recent call last): File "C:\Python39\lib\site-packages\chat_exporter\chat_exporter.py", line 44, in export return (await Transcript.export(channel, limit, set_timezone)).html File "C:\Python39\lib\site-packages\chat_exporter\chat_exporter.py", line 129, in export transcript = await Transcript( File "C:\Python39\lib\site-packages\chat_exporter\chat_exporter.py", line 161, in build_transcript message_html += await Message(m, previous_message, self.timezone_string).build_input() File "C:\Python39\lib\site-packages\chat_exporter\chat_exporter.py", line 237, in build_input await self.build_message() File "C:\Python39\lib\site-packages\chat_exporter\chat_exporter.py", line 253, in build_message await self.build_message_template() File "C:\Python39\lib\site-packages\chat_exporter\chat_exporter.py", line 298, in build_message_template await self.generate_message_divider() File "C:\Python39\lib\site-packages\chat_exporter\chat_exporter.py", line 333, in generate_message_divider avatar_url = str(self.message.author.display_avatar) AttributeError: 'Member' object has no attribute 'display_avatar' Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy Failed to send ticket transcript to ticket creator. (ticket-9) Ignoring exception in on_button_click Traceback (most recent call last): File "C:\Python39\lib\site-packages\discord\client.py", line 308, in _run_event await coro(*args, **kwargs) File "F:\ticketbot\modules\tickets.py", line 37, in on_button_click await self.closeTicket(channel, False) File "F:\ticketbot\modules\tickets.py", line 121, in closeTicket await self.createTranscript(ticket_id, channel) File "F:\ticketbot\modules\tickets.py", line 135, in createTranscript await ticketLogChannel.send(file=discord.File(io.BytesIO(transcript.encode()), filename=f"{channel.name}.html")) AttributeError: 'NoneType' object has no attribute 'encode

python 3.9
chat-exporter 1.7.3 (2.1 don't work)
discord 2.0.0a

I have this error. How do I solve it?

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/construct/transcript.py", line 59, in export
return await super().build_transcript()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/construct/transcript.py", line 32, in build_transcript
message_html = await Message(self.messages, self.channel.guild, self.pytz_timezone).gather()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/construct/message.py", line 281, in gather
message_html += await MessageConstruct(
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/construct/message.py", line 67, in construct_message
await self.build_message()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/construct/message.py", line 74, in build_message
await self.build_assets()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/construct/message.py", line 162, in build_assets
for c in self.message.components:
AttributeError: 'Message' object has no attribute 'components'
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy
Command raised an exception: AttributeError: 'NoneType' object has no attribute 'html'

Attachments getting deleted after the original channel is deleted.

DiscordChatExporterPy Version

2.2.2

Discord Version

2.0

Bug Description

So when I created a transcript it showed the attachments in that channel but after deleting the channel discord also deletes the attachments. Hence, the transcript shows just a broken image instead of an attachment.
ss of the transcript after the channel is deleted - https://i.imgur.com/jRiXWpk.png
ss of another transcript when the channel is not deleted - https://i.imgur.com/1rWPOfW.png

There should be an option if someone wants to save raw bytes of attachments in transcript instead of attachment urls.

Bug Traceback

None

Additional Information

None

Hostname Error

image
Traceback (most recent call last):
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\chat_exporter.py", line 36, in export
return (await Transcript.export(channel, limit, set_timezone)).html
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\chat_exporter.py", line 105, in export
timezone_string=timezone(timezone_string))
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\chat_exporter.py", line 123, in build_transcript
message_html += await Message(m, previous_message, self.timezone_string).build_message()
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\chat_exporter.py", line 179, in build_message
await self.build_content()
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\chat_exporter.py", line 241, in build_content
("EDIT", self.time_string_edit, PARSE_MODE_NONE)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\build_html.py", line 27, in fill_out
v = ParseMarkdown(v).standard_message_flow()
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\parse_markdown.py", line 13, in standard_message_flow
self.parse_emoji()
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\parse_markdown.py", line 59, in parse_emoji
self.content = convert_emoji([word for word in self.content])
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\emoji_convert.py", line 111, in convert_emoji
return "".join(convert(ch) for ch in graphemes(string))
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\emoji_convert.py", line 111, in
return "".join(convert(ch) for ch in graphemes(string))
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\emoji_convert.py", line 95, in convert
if valid_src(src):
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\chat_exporter\emoji_convert.py", line 47, in valid_src
req = requests.head(src)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 104, in head
return request('head', url, **kwargs)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 696, in urlopen
self._prepare_proxy(conn)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 964, in _prepare_proxy
conn.connect()
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 359, in connect
conn = self._connect_tls_proxy(hostname, conn)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 506, in connect_tls_proxy
ssl_context=ssl_context,
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl
.py", line 453, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\ssl
.py", line 495, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "C:\Users\yilma\AppData\Local\Programs\Python\Python37\lib\ssl.py", line 807, in _create
raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

TypeError: demojize() got an unexpected keyword argument 'use_aliases' (1.7.3)

DiscordChatExporterPy Version

1.7.3

Discord Version

1.7.3

Bug Description

0|FoxCodeBot | Traceback (most recent call last):
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 44, in export
0|FoxCodeBot | return (await Transcript.export(channel, limit, set_timezone)).html
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 129, in export
0|FoxCodeBot | transcript = await Transcript(
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 161, in build_transcript
0|FoxCodeBot | message_html += await Message(m, previous_message, self.timezone_string).build_input()
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 237, in build_input
0|FoxCodeBot | await self.build_message()
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 249, in build_message
0|FoxCodeBot | await self.build_content()
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 356, in build_content
0|FoxCodeBot | self.message.content = await fill_out(self.guild, message_content, [
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/build_html.py", line 28, in fill_out
0|FoxCodeBot | v = await ParseMarkdown(v).standard_message_flow()
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/parse_markdown.py", line 13, in standard_message_flow
0|FoxCodeBot | await self.parse_emoji()
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/parse_markdown.py", line 62, in parse_emoji
0|FoxCodeBot | self.content = await convert_emoji([word for word in self.content])
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/emoji_convert.py", line 88, in convert_emoji
0|FoxCodeBot | x.append(await convert(ch))
0|FoxCodeBot | File "/home/corebot/.local/lib/python3.9/site-packages/chat_exporter/emoji_convert.py", line 74, in convert
0|FoxCodeBot | shortcode = emoji.demojize(char, use_aliases=True)
0|FoxCodeBot | TypeError: demojize() got an unexpected keyword argument 'use_aliases'
0|FoxCodeBot | Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Bug Traceback

No response

Additional Information

No response

Large numbers of emojis essentially halt the transcription

Issue description
If there is a large quantity of emojis in the messages, the transctiption process exponentially slows down to the point where it takes several minutes to complete, while making the bot unresponsive to any other input for the duration

Steps to reproduce
Get yourself a channel and spam about 150-200 emojis (doesn't matter if in one or multiple messages, doesn't matter if they are all the same or different), then try to transcribe the messages containing these emojis. The emojis alone will cause the transcript to process for about 20 seconds

Suspected cause
I did some digging in the source code and suspect that ultimately, valid_scr from emoji_convert.py is the culprit. This function executes a synchronous HTTP HEAD request to twemoji.maxcdn.com, and from what I have been able to see in the rest of the library, it will do so for each and every individual emoji that is present in the channel

Suggested fix
The obvious fix would be an emoji cache to avoid duplicate calls to twemoji, thereby drastically reducing the number of HTTP calls. This alone should deal with 80% of the issue. Switching to asynchronous calls (e.g. using aiohttp instead of the requests module) should help to further improve the performance and ensure that the bot stays responsive throughout the transcription process (in the worst case of 200 different emojis, asynchronous HTTP calls will be necessary)

'NoneType' object has no attribute 'html'

DiscordChatExporterPy Version

2.2.2

Discord Version

disnake 2.5.2

Bug Description

I have been using this library for quite a long time now but recently this error is appearing, which I've never seen previously, when using export().

Bug Traceback

File "/python/lib/python3.8/site-packages/chat_exporter/chat_exporter.py", line 50, in export
    return (
        AttributeError: 'NoneType' object has no attribute 'html'

Additional Information

This only happens sometimes, not all the time - but it is increasing in frequency.

AttributeError: 'Message' object has no attribute 'components'

DiscordChatExporterPy Version

2.2.2

Discord Version

1.7.3

Bug Description

I tried to archive that but instead of that it is archiving the channel it spits 2 errors out, tried like the documentation did and copyied that and if u try to execute that command, it will come that error out AttributeError: 'Message' object has no attribute 'components'

Bug Traceback

Traceback (most recent call last):
  File "C:\Users\Jonas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chat_exporter\construct\transcript.py", line 74, in export
    return await super().build_transcript()
  File "C:\Users\Jonas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chat_exporter\construct\transcript.py", line 39, in build_transcript
    message_html = await Message(
  File "C:\Users\Jonas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chat_exporter\construct\message.py", line 302, in gather    
    message_html += await MessageConstruct(
  File "C:\Users\Jonas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chat_exporter\construct\message.py", line 69, in construct_message
    await self.build_message()
  File "C:\Users\Jonas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chat_exporter\construct\message.py", line 76, in build_message
    await self.build_assets()
  File "C:\Users\Jonas\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\chat_exporter\construct\message.py", line 163, in build_assets
    for c in self.message.components:
AttributeError: 'Message' object has no attribute 'components'
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Additional Information

And this is the code i used:

@client.command()
@commands.has_role(MANAGEMENT_ROLE_ID)
async def archive(ctx: commands.Context): 
    transcript = await chat_exporter.export(
        ctx.channel,
        tz_info="UTC",
        military_time=True, 
        bot=client
        )
    if transcript is None:
        return

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

I can't create a new transcript

DiscordChatExporterPy Version

2.2.1

Discord Version

1.7.2

Bug Description

When i wanted to create a new transcript, it shows me this error:

Bug Traceback

Traceback (most recent call last):
  File "C:\Python\fantasupport\venv\lib\site-packages\chat_exporter\construct\transcript.py", line 74, in export
    return await super().build_transcript()
  File "C:\Python\fantasupport\venv\lib\site-packages\chat_exporter\construct\transcript.py", line 39, in build_transcript
    message_html = await Message(
  File "C:\Python\fantasupport\venv\lib\site-packages\chat_exporter\construct\message.py", line 302, in gather
    message_html += await MessageConstruct(
  File "C:\Python\fantasupport\venv\lib\site-packages\chat_exporter\construct\message.py", line 69, in construct_message
    await self.build_message()
  File "C:\Python\fantasupport\venv\lib\site-packages\chat_exporter\construct\message.py", line 76, in build_message
    await self.build_assets()
  File "C:\Python\fantasupport\venv\lib\site-packages\chat_exporter\construct\message.py", line 163, in build_assets
    for c in self.message.components:
AttributeError: 'Message' object has no attribute 'components'
Ignoring exception in command save:
Traceback (most recent call last):
  File "C:\Python\fantasupport\venv\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "C:\Python\fantasupport\test.py", line 16, in save
    await chat_exporter.export(ctx)
  File "C:\Python\fantasupport\venv\lib\site-packages\chat_exporter\chat_exporter.py", line 50, in export
    return (
AttributeError: 'NoneType' object has no attribute 'html'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Python\fantasupport\venv\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Python\fantasupport\venv\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "C:\Python\fantasupport\venv\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'html'

Additional Information

No response

Overwriting emoji namespacing

DiscordChatExporterPy Version

2.2 (Latest)

Discord Version

2.0.1 (Latest)

Bug Description

This bug keeps happening when I try to create a transcript with my Discord py bot. It worked great for 4 days or so and suddenly this error pops up. I had it fixed for an hour today, when I restarted the whole Bot after uninstalling chat-exporter and reinstalling it. This is NOT a duplicate of the issue of the top resolved issues, as my Version numbers should match.

Bug Traceback

https://pastebin.com/GetfeaBz

16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/transcript.py", line 74, in export
16.09 23:25:18 [Bot] return await super().build_transcript()
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/transcript.py", line 39, in build_transcript
16.09 23:25:18 [Bot] message_html = await Message(
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 297, in gather
16.09 23:25:18 [Bot] message_html += await MessageConstruct(
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 69, in construct_message
16.09 23:25:18 [Bot] await self.build_message()
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 76, in build_message
16.09 23:25:18 [Bot] await self.build_assets()
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 167, in build_assets
16.09 23:25:18 [Bot] self.reactions += await Reaction(r, self.guild).flow()
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/assets/reaction.py", line 13, in flow
16.09 23:25:18 [Bot] await self.build_reaction()
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/assets/reaction.py", line 25, in build_reaction
16.09 23:25:18 [Bot] await self.create_standard_emoji()
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/assets/reaction.py", line 37, in create_standard_emoji
16.09 23:25:18 [Bot] react_emoji = await convert_emoji(self.reaction.emoji)
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/ext/emoji_convert.py", line 88, in convert_emoji
16.09 23:25:18 [Bot] x.append(await convert(ch))
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/ext/emoji_convert.py", line 74, in convert
16.09 23:25:18 [Bot] shortcode = emoji.demojize(char, use_aliases=True)
16.09 23:25:18 [Bot] AttributeError: module 'emoji' has no attribute 'demojize'
16.09 23:25:18 [Bot] Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy
16.09 23:25:18 [Bot] [2022-09-17 00:25:18] [[ERROR] ] discord.client: Ignoring exception in on_interaction
16.09 23:25:18 [Bot] Traceback (most recent call last):
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/discord/client.py", line 409, in _run_event
16.09 23:25:18 [Bot] await coro(*args, **kwargs)
16.09 23:25:18 [Bot] File "/bot.py", line 251, in on_interaction
16.09 23:25:18 [Bot] transcript = await chat_exporter.export(channel)
16.09 23:25:18 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 50, in export
16.09 23:25:18 [Bot] return (
16.09 23:25:18 [Bot] AttributeError: 'NoneType' object has no attribute 'html'

Additional Information

No response

what is this

Traceback (most recent call last):
File "C:\Users\user\Documents\GitHub\p-pg-ticketbot\main.py", line 2, in
from discord.ext import commands
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord_init_.py", line 25, in
from .client import Client
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 53, in
from .webhook import Webhook
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\webhook_init_.py", line 12, in
from .async_ import *
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\webhook\async_.py", line 49, in
from ..channel import PartialMessageable
ImportError: cannot import name 'PartialMessageable' from 'discord.channel' (C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\channel.py)

I get this error whenever i use the command

Error during transcript generation!
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/chat_exporter.py", line 55, in quick_export
transcript = await Transcript.export(ctx.channel, None, "Europe/London")
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/chat_exporter.py", line 100, in export
transcript = await Transcript(channel=channel, guild=channel.guild, messages=messages,
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/chat_exporter.py", line 119, in build_transcript
message_html += await Message(m, previous_message, self.timezone_string).build_message()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/chat_exporter.py", line 175, in build_message
await self.build_reference()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/chat_exporter/chat_exporter.py", line 244, in build_reference
message: discord.Message = await self.message.channel.fetch_message(self.message.reference.message_id)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/abc.py", line 970, in fetch_message
data = await self._state.http.get_message(channel.id, id)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 241, in request
raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 20002): Only bots can use this endpoint

Incorrect formatting with role mentions in message content with an embed.

This is very similair to my previous #10 issue, but this time it's inside the content of the message and not the embed itself. Here are 2 screenshots. (It's all 1 message sent by the bot: ctx.channel.send(content=mentions, embed=embed))
I'm not sure if this is specifically tied to role mentions or that's also user mentions, I have not tested that since my bot only allows role mentions.

Formatting with the exporter:
Capture

Formatting on Discord:
Capture

AttributeError: 'NoneType' object has no attribute 'history'

DiscordChatExporterPy Version

2.2.1

Discord Version

2.0.1

Bug Description

Been using your chat-exporter for a while and it has been great, had the issue when I upgraded to discord.py 2.0+ but fixed the issue and it had been running smoothly until today.

Was archiving as I normally do and for some reason it threw me a NoneType error which was very odd since other channels in the same category worked without a hitch. My guess is a perms issue but im not too sure, hoping maybe you would have some insight into this issue.

Thanks!

Bug Traceback

[2022-09-11 17:38:04] [ERROR ] discord.ext.commands.bot: Ignoring exception in command archivechannel
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 190, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Administrator\Archiver.py", line 49, in archivechannel
transcript = await chat_exporter.export(ch)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\chat_exporter.py", line 51, in export
await Transcript(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\construct\transcript.py", line 70, in export
self.messages = [message async for message in self.channel.history(limit=self.limit)]
AttributeError: 'NoneType' object has no attribute 'history'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 1347, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 986, in invoke
await injected(*ctx.args, **ctx.kwargs) # type: ignore
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 199, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'history'

Additional Information

No response

Member object has no attribute display_icon

DiscordChatExporterPy Version

2.2

Discord Version

pycord 2.0.0rc1

Bug Description

Calling chat_exporter.export on a channel where there is a bot with no profile picture set results in a traceback. Maybe this libraray doesn't work with pycord but discord.py instead ?

Also : the guild does not have a profile picture either, that might be it

Bug Traceback

Traceback (most recent call last): File "C:\Users\natha\PycharmProjects\TalyaBot\venv\AppData\Local\Programs\Python\Python\lib\site-packages\chat_exporter\construct\transcript.py", line 74, in export return await super().build_transcript() File "C:\Users\natha\PycharmProjects\TalyaBot\venv\AppData\Local\Programs\Python\Python\lib\site-packages\chat_exporter\construct\transcript.py", line 39, in build_transcript message_html = await Message( File "C:\Users\natha\PycharmProjects\TalyaBot\venv\AppData\Local\Programs\Python\Python\lib\site-packages\chat_exporter\construct\message.py", line 297, in gather message_html += await MessageConstruct( File "C:\Users\natha\PycharmProjects\TalyaBot\venv\AppData\Local\Programs\Python\Python\lib\site-packages\chat_exporter\construct\message.py", line 69, in construct_message await self.build_message() File "C:\Users\natha\PycharmProjects\TalyaBot\venv\AppData\Local\Programs\Python\Python\lib\site-packages\chat_exporter\construct\message.py", line 77, in build_message await self.build_message_template() File "C:\Users\natha\PycharmProjects\TalyaBot\venv\AppData\Local\Programs\Python\Python\lib\site-packages\chat_exporter\construct\message.py", line 173, in build_message_template await self.generate_message_divider() File "C:\Users\natha\PycharmProjects\TalyaBot\venv\AppData\Local\Programs\Python\Python\lib\site-packages\chat_exporter\construct\message.py", line 210, in generate_message_divider ("USER_ICON", await self._gather_user_icon(self.message.author), PARSE_MODE_NONE), File "C:\Users\natha\PycharmProjects\TalyaBot\venv\AppData\Local\Programs\Python\Python\lib\site-packages\chat_exporter\construct\message.py", line 256, in _gather_user_icon if member and member.display_icon: AttributeError: 'Member' object has no attribute 'display_icon' Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Additional Information

No response

Incorrect formatting with user mentions within embed descriptions.

When there's a user mention inside an embed, the formatting will be all over the place. This seems to happen only if it's within the description and not a field. I have linked 2 screenshots below.
This issue is relevant to #9, but has another problem besides the emojis.

Formatting with the exporter:
Capture
Formatting on Discord:
Capture

Timzeone not working

DiscordChatExporterPy Version

Latest

Discord Version

Latest

Bug Description

I am attempting to change the timzeone from UTC over to PST.

According to your docs I notice that it should work by adding to the kwargs like so:

await chat_exporter.export(ctx.channel, limit=1, tz_info="PST")

fails and produces this:

Traceback (most recent call last):
  File "/home/auroratrades/public_python/chatExport/DiscordChatExporterPy/chat_exporter/construct/transcript.py", line 74, in export
    return await super().build_transcript()
  File "/home/auroratrades/public_python/chatExport/DiscordChatExporterPy/chat_exporter/construct/transcript.py", line 39, in build_transcript
    message_html = await Message(
  File "/home/auroratrades/public_python/chatExport/DiscordChatExporterPy/chat_exporter/construct/message.py", line 302, in gather
    message_html += await MessageConstruct(
  File "/home/auroratrades/public_python/chatExport/DiscordChatExporterPy/chat_exporter/construct/message.py", line 59, in __init__
    self.message_created_at, self.message_edited_at = self.set_time()
  File "/home/auroratrades/public_python/chatExport/DiscordChatExporterPy/chat_exporter/construct/message.py", line 267, in set_time
    created_at_str = self.to_local_time_str(message.created_at)
  File "/home/auroratrades/public_python/chatExport/DiscordChatExporterPy/chat_exporter/construct/message.py", line 276, in to_local_time_str
    local_time = time.astimezone(timezone(self.pytz_timezone))
  File "/usr/local/lib/python3.8/site-packages/pytz/__init__.py", line 188, in timezone
    raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'PST'
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy
2022-08-18 20:12:12 ERROR    discord.client Ignoring exception in on_message
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/discord/client.py", line 409, in _run_event
    await coro(*args, **kwargs)
  File "main2.py", line 35, in on_message
    transcript = await chat_exporter.export(ctx.channel, limit=1, tz_info="PST")
  File "/home/auroratrades/public_python/chatExport/DiscordChatExporterPy/chat_exporter/chat_exporter.py", line 50, in export
    return (
AttributeError: 'NoneType' object has no attribute 'html'

this fails, even changing the UTC over to PST in the chat_exporter.py for a 'hardcoded' fix seems to produce the same error.

For now while this seems to be broken I will just be hiding the dates and times in the exported chat. is a shame tho

Bug Traceback

No response

Additional Information

No response

Suggestion

Bot to be able to save your discord with all the channels.
Save deleted messages and save the changes to messages.

I'm having issues lately with the library (since I havent used it in a month or 2) and get these errors:

Traceback (most recent call last):
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ui\view.py", line 368, in _scheduled_task
await item.callback(interaction)
File "c:\Users\bert\Downloads\joscheats ticket bot.py", line 130, in Save_transcript_button
transcript = await chat_exporter.export(channel)
File "C:\Users\bert\AppData\Local\Programs\Python\Python38\lib\site-packages\chat_exporter\chat_exporter.py", line 48, in export
return (
AttributeError: 'NoneType' object has no attribute 'html'
I re-pip-installed the library to make sure I got the newest version, on 2.1 now and i get this error...
also set_timezone isnt recognized anymore?

Error on save

Traceback (most recent call last):
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\transcript.py", line 67, in export
return await super().build_transcript()
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\transcript.py", line 37, in build_transcript
message_html = await Message(self.messages, self.channel.guild, self.pytz_timezone).gather()
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 281, in gather
message_html += await MessageConstruct(
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 57, in init
self.message_created_at, self.message_edited_at = self.set_time()
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 252, in set_time
created_at_str = self.to_local_time_str(message.created_at)
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 261, in to_local_time_str
local_time = time.astimezone(timezone(self.pytz_timezone))
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\pytz_init_.py", line 170, in timezone
if zone.upper() == 'UTC':
AttributeError: 'int' object has no attribute 'upper'
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Message Components in wrong order

When exporting a channel with Message Components they will be in the wrong order.

Example:
Discord
Export

As you can see on Discord the buttons are below the embed while in the Export the buttons are above the Embed.

AttributeError: 'NoneType' object has no attribute 'html'

DiscordChatExporterPy Version

2.2.2

Discord Version

1.7.3

Bug Description

Screenshot 2022-09-15 141031
hen i ran my save transcript command i get this error:
https://hastebin.com/zeqecidela.sql

Here is Screenshot
W
Screenshot 2022-09-15 141031

Bug Traceback

Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\discord\client.py", line 382, in _run_event
await coro(*args, **kwargs)
File "C:\Users\xrkzl\OneDrive\Desktop\gaymer\bot.py", line 153, in on_message
verified = discord.utils.get(ctx.guild.roles, name="โ™ฐใƒปVerified")
AttributeError: 'NoneType' object has no attribute 'roles'
Traceback (most recent call last):
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\construct\transcript.py", line 74, in export
return await super().build_transcript()
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\construct\transcript.py", line 39, in build_transcript
message_html = await Message(
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\construct\message.py", line 302, in gather
message_html += await MessageConstruct(
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\construct\message.py", line 69, in construct_message
await self.build_message()
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\construct\message.py", line 76, in build_message
await self.build_assets()
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\construct\message.py", line 158, in build_assets
self.embeds += await Embed(e, self.guild).flow()
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\construct\assets\embed.py", line 57, in flow
await self.build_embed()
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\construct\assets\embed.py", line 145, in build_embed
self.embed = await fill_out(self.guild, embed_body, [
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\ext\html_generator.py", line 38, in fill_out
base = base.replace("{{" + k + "}}", v)
TypeError: replace() argument 2 must be str, not _EmptyEmbed
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy
Ignoring exception in command savetran:
Traceback (most recent call last):
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\discord\commands\core.py", line 122, in wrapped
ret = await coro(arg)
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\discord\commands\core.py", line 829, in _invoke
await self.callback(ctx, **kwargs)
File "C:\Users\xrkzl\OneDrive\Desktop\gaymer\bot.py", line 1594, in savetran
transcript = await chat_exporter.export(ctx.channel)
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\chat_exporter\chat_exporter.py", line 59, in export
).html
AttributeError: 'NoneType' object has no attribute 'html'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\discord\bot.py", line 1098, in invoke_application_command
await ctx.command.invoke(ctx)
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\discord\commands\core.py", line 331, in invoke
await injected(ctx)
File "C:\Users\xrkzl\AppData\Roaming\Python\Python310\site-packages\discord\commands\core.py", line 128, in wrapped
raise ApplicationCommandInvokeError(exc) from exc
discord.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'NoneType' object has no attribute 'html'

Additional Information

No response

Passing check for exporting.

Allow export() to accept a check function the same way channel.purge() accepts it.

I know I can just pass the check function to purge and it would only return the messages that got deleted. But for uses other than exporting deleted messages where I want to have checks on what messages are extracted.

error exporting

this is the fork i'm using
the bot is running on python 3.9
when i attempted to create logs of a channel it gave me this error:

  File "/home/toby/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 39, in export
    return (await Transcript.export(channel, limit, set_timezone)).html
  File "/home/toby/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 110, in export
    messages = await channel.history(limit=limit).flatten()
  File "/home/toby/.local/lib/python3.9/site-packages/discord/iterators.py", line 120, in flatten
    return [element async for element in self]
  File "/home/toby/.local/lib/python3.9/site-packages/discord/iterators.py", line 120, in <listcomp>
    return [element async for element in self]
  File "/home/toby/.local/lib/python3.9/site-packages/discord/iterators.py", line 124, in __anext__
    return await self.next()
  File "/home/toby/.local/lib/python3.9/site-packages/discord/iterators.py", line 323, in next
    await self.fill_messages()
  File "/home/toby/.local/lib/python3.9/site-packages/discord/iterators.py", line 345, in fill_messages
    if self._get_retrieve():
  File "/home/toby/.local/lib/python3.9/site-packages/discord/iterators.py", line 332, in _get_retrieve
    if l is None or l > 100:
TypeError: '>' not supported between instances of 'Guild' and 'int'
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

AttributeError: module 'disnake' has no attribute 'Client'

DiscordChatExporterPy Version

2.2.2

Discord Version

2.0

Bug Description

I want to clarify that I don't have the ''disnake'' fork, I'm using the basic usage

async def transcript(ctx):
   await chat_exporter.quick_export(ctx.channel)

Bug Traceback

Traceback (most recent call last):
File "c:\Users\FSH\Desktop\uwu\bot.py", line 9, in
import chat_exporter
File "C:\Users\FSH\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter_init_.py", line 1, in
from chat_exporter.chat_exporter import export, raw_export, quick_export, link, quick_link
File "C:\Users\FSH\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\chat_exporter.py", line 4, in
from chat_exporter.construct.transcript import Transcript
File "C:\Users\FSH\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\construct\transcript.py", line 8, in
from chat_exporter.construct.message import Message
File "C:\Users\FSH\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\construct\message.py", line 9, in
from chat_exporter.construct.assets import Attachment, Component, Embed, Reaction
File "C:\Users\FSH\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\construct\assets_init_.py", line 1, in
from .embed import Embed
File "C:\Users\FSH\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\construct\assets\embed.py", line 3, in
from chat_exporter.ext.html_generator import (
File "C:\Users\FSH\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\ext\html_generator.py", line 3, in
from chat_exporter.parse.mention import ParseMention
File "C:\Users\FSH\AppData\Local\Programs\Python\Python310\lib\site-packages\chat_exporter\parse\mention.py", line 6, in
bot: Optional[discord.Client] = None
AttributeError: module 'disnake' has no attribute 'Client'

Additional Information

No response

Error when exporting channel with references

Traceback (most recent call last):
  File "/var/roothome/fallout/fallout/lib64/python3.9/site-packages/chat_exporter/chat_exporter.py", line 46, in raw_export
    return (await Transcript.raw_export(channel, messages, set_timezone)).html
  File "/var/roothome/fallout/fallout/lib64/python3.9/site-packages/chat_exporter/chat_exporter.py", line 109, in raw_export
    transcript = await Transcript(channel=channel, guild=channel.guild, messages=messages,
  File "/var/roothome/fallout/fallout/lib64/python3.9/site-packages/chat_exporter/chat_exporter.py", line 119, in build_transcript
    message_html += await Message(m, previous_message, self.timezone_string).build_message()
  File "/var/roothome/fallout/fallout/lib64/python3.9/site-packages/chat_exporter/chat_exporter.py", line 189, in build_message
    await self.generate_message_divider()
  File "/var/roothome/fallout/fallout/lib64/python3.9/site-packages/chat_exporter/chat_exporter.py", line 213, in generate_message_divider
    self.message_html += await fill_out(self.message.guild, start_message, [
  File "/var/roothome/fallout/fallout/lib64/python3.9/site-packages/chat_exporter/build_html.py", line 36, in fill_out
    base = base.replace("{{" + k + "}}", v)
TypeError: replace() argument 2 must be str, not MessageReference

Code:

            deleted_messages = await new_channel.purge()
            if deleted_messages:
                transcript = await chat_exporter.raw_export(new_channel, deleted_messages, 'Europe/Paris')
                if transcript:
                    for member in new_channel.members:
                        if member.bot:
                            continue
                        file = File(io.BytesIO(transcript.encode()), filename=f'{new_channel.name}.html')
                        await member.send(file=file)

Transcript not generating

DiscordChatExporterPy Version

2.2.2

Discord Version

nextcord 2.2.0

Bug Description

When I was trying to create a new transcript.

Bug Traceback

Traceback (most recent call last): File "/opt/venv/lib/python3.9/site-packages/chat_exporter/construct/transcript.py", line 74, in export return await super().build_transcript() File "/opt/venv/lib/python3.9/site-packages/chat_exporter/construct/transcript.py", line 39, in build_transcript message_html = await Message( File "/opt/venv/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 302, in gather message_html += await MessageConstruct( File "/opt/venv/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 69, in construct_message await self.build_message() File "/opt/venv/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 76, in build_message await self.build_assets() File "/opt/venv/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 158, in build_assets self.embeds += await Embed(e, self.guild).flow() File "/opt/venv/lib/python3.9/site-packages/chat_exporter/construct/assets/embed.py", line 53, in flow await self.build_author() File "/opt/venv/lib/python3.9/site-packages/chat_exporter/construct/assets/embed.py", line 108, in build_author author_icon = await fill_out(self.guild, embed_author_icon, [ File "/opt/venv/lib/python3.9/site-packages/chat_exporter/ext/html_generator.py", line 38, in fill_out base = base.replace("{{" + k + "}}", v) TypeError: replace() argument 2 must be str, not None Ignoring exception in view <closer timeout=None children=1> for item <Button style=<ButtonStyle.danger: 4> url=None disabled=False label='Close' emoji=None row=None>: Traceback (most recent call last): File "/opt/venv/lib/python3.9/site-packages/nextcord/ui/view.py", line 390, in _scheduled_task await item.callback(interaction) File "/app/commands/tickets.py", line 70, in cl transcript = await chat_exporter.export(interaction.channel,limit=None) File "/opt/venv/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 50, in export return ( AttributeError: 'NoneType' object has no attribute 'html'

Additional Information

I found out that this is becuase nextcord now returns a NoneType object when any embed field is empty instead of Embed.Empty so please consider fixing this issue.

Error attribute 'components'

Traceback (most recent call last):
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\transcript.py", line 67, in export
return await super().build_transcript()
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\transcript.py", line 37, in build_transcript
message_html = await Message(self.messages, self.channel.guild, self.pytz_timezone).gather()
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 281, in gather
message_html += await MessageConstruct(
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 67, in construct_message
await self.build_message()
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 74, in build_message
await self.build_assets()
File "C:\Users\Developer\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 162, in build_assets
for c in self.message.components:
AttributeError: 'Message' object has no attribute 'components'
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Transcript Just Stops

I'm using chat exporter for a ticket system however the transcripts do not work sometimes. I've tried many things to figure out the issue but its random. It stops with/without videos, pictures, files, basically everything. I've ramped down the amount of messages which hasn't done much.

This is what I'm currently using

transcript = await chat_exporter.export(ctx.channel, limit=200, set_timezone="America/Chicago") transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f'transcript-{ctx.channel.name}.html')

I believe it's based on my specs because it works 100% on my PC while it stops on my VPS but I really don't know because as I said it's random when it works or not.

TypeError: demojize() got an unexpected keyword argument 'use_aliases'

DiscordChatExporterPy Version

2.2.1

Discord Version

0.0.1

Bug Description

I have a command that sends the transcript of a channel when that channel is deleted. When I tried to delete a channel, it errored.

cogs.tickets

    @bridge.bridge_command(aliases=["del"])
    @commands.has_role("Staff")
    async def delete(self, ctx):
        """Delete a ticket!"""
        res = await General.delete(ctx)
        if res:
            await ctx.respond(res)

general.py

   async def delete(ctx):
        embed = discord.Embed(title="This ticket will be deleted in 10 seconds!", color=neg_color)
        if ("MILESTONES" == ctx.channel.category.name) or not ctx.channel.category or ctx.channel.category.name not in ticket_categories.values():
            return "This command cannot be used here"
        if ctx.channel.category.name == ticket_categories["registrees"]:
            member = await get_ticket_creator(ctx.channel)
            if member:
                ign, uuid = await get_mojang_profile(await name_grabber(member))
                await Union(user=member).sync(ctx, ign, None, True)
                embed.set_footer(text=f"{ign}'s roles have been updated automatically!")

        # Send deletion warning and gather transcript
        await ctx.respond(embed=embed)
        transcript = await create_transcript(ctx.channel)

        # Sleep and delete channel
        await asyncio.sleep(10)
        await discord.TextChannel.delete(ctx.channel)

        if transcript:
            # Log outcome
            await log_event(f"{ctx.channel.name} was deleted by {ctx.author}")
            await (await bot.fetch_user(ctx.channel.topic.split("|")[0])).send(embed=ticket_deleted_embed.set_footer(text=ctx.channel.name), file=transcript)
            await bot.get_channel(log_channel_id).send(file=transcript)

Bug Traceback

Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/transcript.py", line 74, in export
return await super().build_transcript()
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/transcript.py", line 39, in build_transcript
message_html = await Message(
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 302, in gather
message_html += await MessageConstruct(
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 69, in construct_message
await self.build_message()
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 76, in build_message
await self.build_assets()
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 164, in build_assets
self.components += await Component(c, self.guild).flow()
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/assets/component.py", line 100, in flow
await self.build_component(c)
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/assets/component.py", line 43, in build_component
await self.build_menu(c)
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/assets/component.py", line 68, in build_menu
content = await self.build_menu_options(options)
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/construct/assets/component.py", line 82, in build_menu_options
content.append(await fill_out(self.guild, component_menu_options_emoji, [
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/ext/html_generator.py", line 36, in fill_out
v = await ParseMarkdown(v).special_emoji_flow()
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/parse/markdown.py", line 48, in special_emoji_flow
await self.parse_emoji()
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/parse/markdown.py", line 62, in parse_emoji
self.content = await convert_emoji([word for word in self.content])
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/ext/emoji_convert.py", line 88, in convert_emoji
x.append(await convert(ch))
File "/home/container/.local/lib/python3.9/site-packages/chat_exporter/ext/emoji_convert.py", line 74, in convert
shortcode = emoji.demojize(char, use_aliases=True)
TypeError: demojize() got an unexpected keyword argument 'use_aliases'

Additional Information

No response

Embed not showing correctly

Hey there,

I found two issues with the embeds in general. First one is the embed field always shows as inline=True and the other one is that markdown links inside the embed show as row text. Here is two photos showing the difference.

html
discord

Embeds(?) stopping exporting

Traceback (most recent call last):
  File "C:\Users\Waili\AppData\Local\Programs\Python\Python38\lib\site-packages\chat_exporter\chat_exporter.py", line 61, in quick_export     
    transcript = await Transcript.export(ctx.channel, None, "Europe/London")
  File "C:\Users\Waili\AppData\Local\Programs\Python\Python38\lib\site-packages\chat_exporter\chat_exporter.py", line 115, in export
    transcript = await Transcript(
  File "C:\Users\Waili\AppData\Local\Programs\Python\Python38\lib\site-packages\chat_exporter\chat_exporter.py", line 147, in build_transcript
    message_html += await Message(m, previous_message, self.timezone_string).build_message()
  File "C:\Users\Waili\AppData\Local\Programs\Python\Python38\lib\site-packages\chat_exporter\chat_exporter.py", line 213, in build_message   
    await self.build_reference()
  File "C:\Users\Waili\AppData\Local\Programs\Python\Python38\lib\site-packages\chat_exporter\chat_exporter.py", line 315, in build_reference 
    if not self.message.reference:
AttributeError: 'Message' object has no attribute 'reference'
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

The error i get.

Error when saving chat

I've encountered the following error. This may be related to some of the new features of Discord, but I'm unsure as I've not used this library in a while.

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/chat_exporter/chat_exporter.py", line 36, in export
    return (await Transcript.export(channel, limit, set_timezone)).html
  File "/usr/local/lib/python3.10/site-packages/chat_exporter/chat_exporter.py", line 100, in export
    transcript = await Transcript(channel=channel, guild=channel.guild, messages=messages,
  File "/usr/local/lib/python3.10/site-packages/chat_exporter/chat_exporter.py", line 119, in build_transcript
    message_html += await Message(m, previous_message, self.timezone_string).build_message()
  File "/usr/local/lib/python3.10/site-packages/chat_exporter/chat_exporter.py", line 189, in build_message
    await self.generate_message_divider()
  File "/usr/local/lib/python3.10/site-packages/chat_exporter/chat_exporter.py", line 213, in generate_message_divider
    self.message_html += await fill_out(self.message.guild, start_message, [
  File "/usr/local/lib/python3.10/site-packages/chat_exporter/build_html.py", line 36, in fill_out
    base = base.replace("{{" + k + "}}", v)
TypeError: replace() argument 2 must be str, not MessageReference
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.

DiscordChatExporterPy Version

v2.2.2

Discord Version

py-cord v2.0.0rc1

Bug Description

I'm using this to log transcripts for my ticket bot and when I try closing already created tickets I get the error message "Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.". I just tested with a few new tickets and its working fine with them but with older tickets it gives that error

Bug Traceback

Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.

Additional Information

Screenshot_1

Basic example errors

DiscordChatExporterPy Version

2.2.2

Discord Version

2.0.0

Bug Description

Used the example in the README

channel = ctx.channel
archive_channel = ctx.guild.get_channel(1006895272565166130)

    if channel and archive_channel:
       transcript = await chat_exporter.export(channel=channel)
       transcript_file = discord.File(io.BytesIO(transcript.encode()),
                                       filename=f"{channel.name}.html")

       await archive_channel.send(file=transcript_file)

For the first error there was a embed in the channel that had no color (default) after giving the embed a color and trying again gave me the 2nd error.

The only message that is in the channel is 1 embed with only no title

Bug Traceback

Traceback (most recent call last):
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\transcript.py", line 74, in export
    return await super().build_transcript()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\transcript.py", line 39, in build_transcript
    message_html = await Message(
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 302, in gather
    message_html += await MessageConstruct(
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 69, in construct_message
    await self.build_message()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 76, in build_message
    await self.build_assets()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 158, in build_assets
    self.embeds += await Embed(e, self.guild).flow()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\assets\embed.py", line 49, in flow
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\assets\embed.py", line 63, in build_colour
    (self.embed.colour.r, self.embed.colour.g, self.embed.colour.b)
AttributeError: 'NoneType' object has no attribute 'r'
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy
Traceback (most recent call last):
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\transcript.py", line 74, in export
    return await super().build_transcript()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\transcript.py", line 39, in build_transcript
    message_html = await Message(
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 302, in gather
    message_html += await MessageConstruct(
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 69, in construct_message
    await self.build_message()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 76, in build_message
    await self.build_assets()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\message.py", line 158, in build_assets
    self.embeds += await Embed(e, self.guild).flow()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\assets\embed.py", line 57, in flow
    await self.build_embed()
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\construct\assets\embed.py", line 145, in build_embed
    self.embed = await fill_out(self.guild, embed_body, [
  File "C:\Users\wilde\AppData\Local\Programs\Python\Python39\lib\site-packages\chat_exporter\ext\html_generator.py", line 38, in fill_out
    base = base.replace("{{" + k + "}}", v)
TypeError: replace() argument 2 must be str, not None
Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy

Additional Information

No response

Wrong avatar shown for replied-to messages

First of all, awesome work with this project so far. I was glad to see somebody had made a Python version of this which makes it way easier to integrate into a Python-based bot than the original .NET one.

One very minor thing I noticed though is that the wrong avatar is shown for the author of a replied-to message. Instead of showing the author of the original message, it seems to show the author of the new message twice:

Expected (as seen in Discord web client):

image

Actual (as seen in exported transcript):

image

Colon-delimited :standard_emoji: aren't properly converted to graphical emoji in transcript

When I send a colon-delimited standard emoji, such as :thumbsup, in a message using discord.py, the Discord web client renders the emoji as the actual graphical representation ๐Ÿ‘. The exported transcript still renders it as the :thumbsup: text though, instead of the graphic. Note that this only happens when a colon-delimited emoji is sent directly with discord.py (and probably other libraries), but not when sent from the standard web client. (I suspect the web client might be pre-processing the message to replace the emoji on the client side before it's sent, but I don't have anything to back that up.)

Python code to send message from discord.py Cog class:

@commands.command
async def gimme_thumbs_up(self, ctx):
    await ctx.send('ok :thumbs_up:')

Expected (as seen in Discord web client):

image

Actual (as seen in exported transcript):

image

AttributeError: 'Message' object has no attribute 'components'

So, I am trying to use quick_export, however, I am getting a NoneType issue.

Error

14.04 21:05:49 [Bot] Traceback (most recent call last):
14.04 21:05:49 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/transcript.py", line 67, in export
14.04 21:05:49 [Bot] return await super().build_transcript()
14.04 21:05:49 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/transcript.py", line 37, in build_transcript
14.04 21:05:49 [Bot] message_html = await Message(self.messages, self.channel.guild, self.pytz_timezone).gather()
14.04 21:05:49 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 281, in gather
14.04 21:05:49 [Bot] message_html += await MessageConstruct(
14.04 21:05:49 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 67, in construct_message
14.04 21:05:49 [Bot] await self.build_message()
14.04 21:05:49 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 74, in build_message
14.04 21:05:49 [Bot] await self.build_assets()
14.04 21:05:49 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/construct/message.py", line 162, in build_assets
14.04 21:05:49 [Bot] for c in self.message.components:
14.04 21:05:49 [Bot] AttributeError: 'Message' object has no attribute 'components'
14.04 21:05:49 [Bot] Please send a screenshot of the above error to https://www.github.com/mahtoid/DiscordChatExporterPy
14.04 21:05:49 [Bot] Ignoring exception in on_button_click
14.04 21:05:49 [Bot] Traceback (most recent call last):
14.04 21:05:49 [Bot] File "/.local/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
14.04 21:05:49 [Bot] await coro(*args, **kwargs)
14.04 21:05:49 [Bot] File "/hbot/events/buttons.py", line 227, in on_button_click
14.04 21:05:49 [Bot] transcript = await chat_exporter.quick_export(interaction.channel)
14.04 21:05:49 [Bot] File "/.local/lib/python3.9/site-packages/chat_exporter/chat_exporter.py", line 16, in quick_export
14.04 21:05:49 [Bot] transcript = (
14.04 21:05:52 [Bot] AttributeError: 'NoneType' object has no attribute 'html'

Code:

elif interaction.component.custom_id == ("archyes"):
        channel = await self.bot.fetch_channel('953298647473328178')
        embedVar=discord.Embed(title = interaction.channel.name, description = f'{interaction.user.mention} has archived ``#{interaction.channel.name}``', color = 14177041)
        embedVar.timestamp = datetime.datetime.utcnow()
        embedVar.set_footer(text='\u200b')
        await interaction.channel.purge(limit=1, check=None, before=None)
        transcript = await chat_exporter.quick_export(interaction.channel)
        transcript_file = discord.File(io.BytesIO(transcript.encode()), filename=f"{interaction.channel.name}.html")
        await channel.send(file=transcript_file, embed = embedVar)
        await interaction.channel.delete()

ASK

How to install chat_exporter 1.73?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.