Skip to content

Repository files navigation

Thread It 🧵

CI Docker Python Discord.py Container License

A Discord bot that automatically keeps channels clean by converting message replies into organized public threads. Thread It promotes organized conversations by seamlessly moving reply discussions into dedicated threads, preventing channel clutter while maintaining context.

Add to Discord

📋 Table of Contents

✨ Features

  • Automatic Thread Creation: Converts message replies into organized public threads
  • Clean Channel Management: Keeps main channels clutter-free by moving discussions to threads
  • Smart Thread Naming: Automatically generates meaningful thread names from original message content
  • Seamless Operation: Works in the background without requiring manual commands
  • Content Preservation: Maintains all reply content including text, attachments, and embeds
  • Permission Validation: Ensures proper bot permissions before attempting operations
  • Comprehensive Logging: Detailed logging for monitoring and debugging
  • Error Handling: Robust error handling with graceful fallbacks

🔄 How It Works

  1. User posts a message in a Discord channel
  2. Another user replies to that message
  3. Thread It detects the reply and automatically:
    • Creates a public thread on the original message
    • Moves the reply content into the new thread
    • Removes the original reply from the main channel
    • Preserves all attachments, embeds, and formatting

The result: Clean main channels with organized discussions in dedicated threads!

Video Demo
Thread-It.mp4

🚀 Installation

One-Click Installation

The easiest way to get Thread It running on your Discord server is to clicking Add to Discord. This will guide you through the process of inviting the bot to your server with the necessary permissions.

Manual Setup (for self-hosting or development)

If you prefer to self-host Thread It or want to contribute to its development, follow these steps:

Prerequisites

  • Python 3.13 or higher
  • A Discord bot token
  • Discord server with appropriate permissions

Step 1: Clone the Repository

git clone https://github.com/wei/thread-it.git
cd thread-it

Step 2: Set Up Virtual Environment

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

Step 3: Install Dependencies

pip install -r requirements.txt

For development (running tests, linting, type-checking), install the dev extras instead:

pip install -r requirements-dev.txt

Then use:

ruff check .       # lint
mypy bot.py config.py threadit/  # type-check
pytest             # run tests

Step 4: Create Discord Bot

  1. Go to the Discord Developer Portal
  2. Create a new application
  3. Navigate to the "Bot" section
  4. Create a bot and copy the token
  5. Enable the following Privileged Gateway Intents:
    • Message Content Intent (required)
  6. Generate an invite URL with these permissions:
    • View Channels
    • Send Messages
    • Send Messages in Threads
    • Create Public Threads
    • Manage Messages
    • Read Message History
    • Embed Links
    • Attach Files

Step 5: Configure Environment Variables

# Copy the example environment file
cp .env.example .env

# Edit .env with your bot token
# DISCORD_TOKEN=your_bot_token_here
# LOG_LEVEL=INFO

Step 6: Run the Bot

python bot.py

See the Deployment Guide for production docker deployment instructions.

📖 Usage

Once installed and running, Thread It works automatically — just reply to a message and a thread is created. No commands required for the core feature.

For help and a live permission check in the current channel, use the /thread-it slash command (preferred) or the legacy text command !thread-it. Both produce the same output; the slash version replies ephemerally so only you see it.

Example Workflow

Main Channel:
👤 Alice: "What's everyone's favorite Python library?"

👤 Bob: "I love requests for HTTP calls!" (replies to Alice's message)

Result: Thread It automatically creates a thread titled "What's everyone's favorite Python library?" and moves Bob's reply into it.

Supported Content Types

  • ✅ Text messages (re-posted inside an attribution embed)
  • ✅ Images and attachments (re-uploaded; per-file size cap defaults to 25 MiB)
  • ✅ Original embeds (a new attribution embed is prepended; the original embeds follow)
  • ✅ Message formatting (bold, italic, code blocks, etc.)
  • ✅ Mentions and links (cleaned from thread names; @everyone / @here stripped)

Bot Behavior

  • Ignores bot messages: Prevents infinite loops
  • Only processes replies: Regular messages are left untouched
  • Skips existing threads: Won't create threads within threads
  • Validates permissions: Checks required permissions before acting
  • Sends helpful notifications: Briefly notifies users where to continue their conversation (auto-deletes after 8 seconds)
  • Handles errors gracefully: Logs issues without crashing

🔐 Required Permissions

Thread It requires specific Discord permissions to function properly. When inviting the bot to your server, ensure these permissions are granted:

Bot Permissions

Permission Purpose
View Channels Read messages in channels
Send Messages Send messages in main channels
Send Messages in Threads Send messages in created threads
Create Public Threads Create threads on messages
Manage Messages Delete original reply messages
Read Message History Access message history for context
Embed Links Post reply content as embeds in threads
Attach Files Re-upload reply attachments into threads

Gateway Intents

The following intents must be enabled in the Discord Developer Portal:

  • Message Content Intent (Privileged): Required to read message content

Permission Issues?

If you're experiencing permission-related problems, see our Troubleshooting Guide for detailed solutions.

📞 Support & Documentation

Getting Help

Quick Links

🤝 Contributing

We welcome contributions to Thread It! Whether you want to fix bugs, add features, or improve documentation, your help is appreciated.

Quick Start for Contributors:

  1. Read the Contributing Guide
  2. Fork the repository
  3. Set up your development environment
  4. Make your changes
  5. Submit a pull request

For detailed development setup, code style guidelines, testing requirements, and submission process, see our comprehensive Contributing Guide.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License Summary: You can use, modify, and distribute this project freely for commercial or private use. No warranty is provided.


🙏 Acknowledgments

  • Discord.py - The excellent Python library for Discord bot development
  • Discord - For providing the platform and API
  • Contributors - Everyone who has contributed to making Thread It better
  • Community - Users who provide feedback and report issues

About

🧵 A Discord bot that keeps channels clean by converting replies into threads.

Resources

Contributing

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages