Metadata-Version: 2.4
Name: discord-export-dredger
Version: 1.1.0
Summary: A quick and simple library to dredge through the Discord export package from the Request A Copy of Your Data option on Discord, since the internal file structure and just looking through it by hand is a bit of a pain.
Project-URL: Homepage, https://pypi.org/project/discord-export-dredger/
Project-URL: Repository, https://github.com/poliwhirl555/discord-export-dredger
Project-URL: Issues, https://github.com/poliwhirl555/discord-export-dredger/issues
License-File: LICENSE
Requires-Python: >=3.13
Description-Content-Type: text/markdown

# Discord Message Dredger

A quick and simple library to dredge through the Discord export package from the [Request A Copy of Your Data](https://support.discord.com/hc/en-us/articles/360004027692-Requesting-a-Copy-of-your-Data) option on Discord, since the internal file structure and just looking through it by hand is a bit of a pain.

## Installation

```
python3 -m pip install discord-export-dredger
```

## Usage

```cmd
usage: dredger.py [-h] [-dm USERNAME] [-c CHANNEL SERVER] [-gc GROUP_CHAT] [-sl SAVE_LOCATION] package

positional arguments:
  package               the name or path path from current directory to the Discord data export package to fetch messages from

options:
  -h, --help            show this help message and exit
  -dm, --direct-message USERNAME
                        fetch your DM messages with the provided user in the package. Must use their true Discord username, not their display name.
  -c, --channel CHANNEL SERVER
                        fetch your messages in the specified channel from the specified server.
  -gc, --group-chat GROUP_CHAT
                        fetch your messages in a specified group chat
  -sl, --save-location SAVE_LOCATION
                        location to extract the files to. Current working directory if none provided
```

## Python Library

```Python
class DiscordMessagesExport:
    """
    A representation and extactor for the saved messages in a Discord Request Your Own Data export package.
    """
    def __init__(self, data_package : str):
        """
        Create a new DiscordMessagesExport object with input Discord export package from the Discord Request Your Own Data function.
        
        :param self: this object
        :param data_package: str path to the Discord data export package
        :type data_package: str
        """

    def fetch_chat_with_name(self, name : str, save_path : str = "") -> str:
        """
        Fetch and extrat the chat with input name from the archive package and save it to save_path, 
        or the current working directory if none provided, and return the path to the message.json as a str
        
        :param self: this object
        :param name: name of chat to fetch
        :type name: str
        :param save_path: path to extract the chat to, or the current working directory if none provided
        :type save_path: str
        :return: string path to the messages.json file of the extracted chat
        :rtype: str
        """

    def fetch_channel_json_for_chat_with_name(self, name : str, save_path : str = "") -> str:
        """
        Fetch and extrat the chat and channel.json for the chat with input name from the archive package and save it to save_path, 
        or the current working directory if none provided, and return the path to the message.json as a str
        channel.json comes in format {"id": "1374964094884515882", "type": "DM", "recipients": ["231295438253195264", "793684523774509077"]}
        
        :param self: this object
        :param name: name of chat to fetch channel.json for
        :type name: str
        :param save_path: path to extract the chat and channel.json to, or the current working directory if none provided
        :type save_path: str
        :return: string path to the channel.json file of the extracted chat
        :rtype: str
        """

    def get_Direct_Message(self, recipient_username : str, save_path : str = "") -> str:
        """
        Extract and return the path to the messages.json file of the Direct Message chat with the user with recipient_username.
        
        :param self: this object
        :param recipient_username: username of the other side of the direct message chat
        :type recipient_username: str
        :param save_path: path to extract the chat to, or the current working directory if none provided
        :type save_path: str
        :return: string path to the messages.json file of the extracted chat
        :rtype: str
        """

    def get_Channel(self, channel_name : str, server_name : str, save_path : str = "") -> str:
        """
        Extract and return the path to the messages.json file of the input channel chat in input server.
        
        :param self: this object
        :param channel_name: name of the channel in the server to fetch the message.json of
        :type channel_name: str
        :param server_name: the server that the input channel is in
        :type server_name: str
        :param save_path: path to extract the chat to, or the current working directory if none provided
        :type save_path: str
        :return: string path to the messages.json file of the extracted chat
        :rtype: str
        """

    def get_Group_Chat(self, group_chat_name : str, save_path : str = "") -> str:
        """
        Extract and return the path to the messages.json file of the group chat with input name.
        
        :param self: this object
        :param group_chat_name: name of group chat to fetch the message.json of
        :type group_chat_name: str
        :param save_path: path to extract the chat to, or the current working directory if none provided
        :type save_path: str
        :return: string path to the messages.json file of the extracted chat
        :rtype: str
        """

    @staticmethod
    def fetch_channel_info_from_chat_path(chat_path : str) -> str:
        """
        Given the path to a message.json, fetch the channel.json associated with it.
        channel.json comes in format {"id": "1374964094884515882", "type": "DM", "recipients": ["231295438253195264", "793684523774509077"]}
        
        :param chat_path: path to message.json
        :type chat_path: str
        :return: str path to channel.json for the message.json
        :rtype: str
        """
        return str(pathlib.Path(chat_path).parent / "channel.json")
```

## Note
If this was useful for you, let me know with a Star, Watch, or comment in Discussions on Github. It's just nice to know that someone out there got use out of my code since there's really no way to tell otherwise.

## Changelog

### V 1.0.0
- Initial Release

### V 1.1.0
- Added ability to fetch the channel.json via either path to message.json or via name of chat