A powerful, real-time Discord chat logger for server channels, DMs, and group chats.
- About The Project
- Features
- Disclaimer
- Prerequisites
- Installation
- Usage
- File Structure
- How It Works
- Contributing
- License
- Acknowledgments
The Discord Message Logger is a command-line tool designed to provide a persistent, local backup of your Discord conversations. Whether you want to archive important discussions in a server, keep a personal log of your DMs, or monitor group chats, this tool offers a simple and effective solution.
It runs directly on your machine and connects to Discord using a user token, allowing it to see and log everything you have access to.
- Real-time Logging: Captures messages from server channels, direct messages (DMs), and group DMs as they happen.
- Deleted Message Detection: If a message is deleted in a channel you are logging, the script will mark the corresponding entry in your log file as
[DELETED]. - Forwarded Message Logging: When a message is a reply, the logger fetches the original message's author and content, providing full context.
- User-Friendly Token Entry: A simple GUI prompt makes it easy to enter your Discord token, which is then saved securely in a local
.envfile for future use. - Session Management: Each time you restart the logger, it adds a timestamped separator to the log file, making it easy to see when a new session began.
- Filesystem-Safe Naming: Server and channel names are automatically sanitized to prevent issues with folder and file creation.
This tool requires a Discord User Token, not a bot token. Using a user token to automate actions is against Discord's Terms of Service and can put your account at risk of being flagged or banned.
Recommendations:
- Use an Alt Account: It is strongly recommended that you DO NOT use your main Discord account. Create a secondary, "alt" or "throwaway" account for logging purposes.
- Understand the Risks: By using this tool, you acknowledge the potential risks to your Discord account. The author is not responsible for any consequences that may arise.
- Python 3.6 or higher: You can download Python from python.org.
- A Discord User Token: You will need to provide a user token from a Discord account.
-
Clone the repository (or download the files):
git clone https://github.com/Gh0styTongue/DiscordMessageLogger cd DiscordMessageLogger -
Install the required Python packages: The script relies on
aiohttpfor asynchronous HTTP requests andtkinterfor the token entry GUI (tkinter is usually included with Python).pip install aiohttp
-
Run the script:
python logger.py
-
Enter Your Token:
- The first time you run the script, a GUI window will pop up asking for your Discord user token.
- Paste your token into the field and click "Save".
- The token will be saved to a
.envfile in the same directory, so you won't have to enter it again unless it becomes invalid. - If the token is ever invalid, the script will automatically prompt you to enter a new one.
-
Select Logging Mode:
- In your terminal, you will be asked to choose between logging Server Channels or DMs.
1) Server channels 2) DMs Select: -
Select Your Target:
- If you chose Servers: You will be presented with a numbered list of servers your account is in. Enter the number corresponding to your desired server. Then, you will see a list of channels in that server. Enter the number for the channel you wish to log.
- If you chose DMs: You will see a numbered list of your recent DMs and group chats. Enter the number for the conversation you want to log.
-
Start Logging:
- The script will immediately begin logging messages in the selected channel or DM. New messages will be printed to the console and saved to a log file.
- To stop the logger, press
Ctrl+Cin your terminal.
The script will create folders and files to store the logs, organized as follows:
Server_Name/
└── live_ChannelName.txt # Log file for a server channel
DMs/
└── live_Username_or_GroupName.txt # Log file for a DM or group chat
Server_NameandChannelName(orUsername) are sanitized versions of the actual names on Discord.
The DiscordLogger class manages the entire logging process. Here's a high-level overview:
- It uses the
aiohttplibrary to make asynchronous GET requests to the Discord API endpoints. - After a valid token is provided, it fetches the user's guilds (servers) and DM channels.
- Once a target channel is selected, it enters an asynchronous loop (
log_loop). - In each iteration, it fetches the last 50 messages from the channel.
- It compares the new message IDs with the IDs it has already logged to identify new messages.
- It also checks if any previously seen messages are now missing, which indicates they were deleted.
- New messages are formatted and appended to the appropriate log file and printed to the console.
- The loop runs with a short delay to avoid hitting API rate limits.
Contributions are welcome! If you have a suggestion or find a bug, please open an issue to discuss it.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
- Copyright (c) 2024 GhostyTongue (Original Author)
- This README was generated and enhanced by an AI assistant.