Tyrrrz / DiscordChatExporter

Exports Discord chat logs to a file
MIT License
7.7k stars 703 forks source link

Export role details in JSON format #1101

Closed slatinsky closed 1 year ago

slatinsky commented 1 year ago

This pull request adds roles field to messages.author in JSON output format.

If no roles are available, empty array is created:

"author": {
    ...
    "roles": [],
    ...
},

If role color is not available, null value is used. Else the color is is converted to hexcode

"roles": [
    {
        "id": "712543702037017113",
        "name": "mod",
        "color": null,
        "position": 239
    },
    {
        "id": "766532373335259678",
        "name": "Orange",
        "color": "#F58231",
        "position": 218
    },
    ...
]

Roles are sorted by position, as they are in the Discord client

Tested CLI export in Json format - DM channel (no roles) and Guild channel (with roles). \ GUI not tested, but the changes should not affect it.

slatinsky commented 1 year ago

In the last commit:

Tyrrrz commented 1 year ago

Thanks!

stepech commented 1 year ago

Hey, thanks for change. Was there some consideration about how large the file will get with this change? Is it recorded really for each message including on servers with 100s of roles? What about creating extra file during export, which would hold just dictionary of users and their corresponding roles, while removing that information from channel export?

slatinsky commented 1 year ago

Discord limits roles to 250 per server. That is the edge case scenario, but many users in my experience have only small number of roles. Yes, it is recorded in every message. You could deduplicate a lot of things if you really wanted - reactions, authors, mentions, stickers. This felt like the best place to put it considering the current state of the project. Yes, it will increase the file size. But text size increase is minimal in my opinion vs. the size of assets. And hard drive space is very cheap. And we were fetching this information anyway, just not recording it in the file.