Skip to main content

A Discord bot that automatically translates messages in specified channels

Project description

Discord Translation Bot

A Discord bot that automatically translates messages in a designated channel to each user's preferred language while maintaining Discord's rich formatting.


📦 Deployment & Installation Guide


Features

  • Automatic translation of messages in a designated channel
  • User language preferences
  • Preserves Discord formatting (emojis, mentions, etc.)
  • Free to use (uses Google Translate API free tier)

Setup (Local Development)

  1. Clone this repository

  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Upgrade pip (required for editable installs with modern packaging):

    python -m pip install --upgrade pip
    
  4. Install the package in editable/development mode from the project root:

    pip install -e .
    

    This makes the discord_trad_bot package available for import and development, and any code changes are picked up instantly.

  5. Create a .env file in the project root with your Discord bot token and Google Translate API key:

    DISCORD_TOKEN=your_discord_bot_token
    GOOGLE_TRANSLATE_API_KEY=your_google_translate_api_key
    

Running the Bot Locally

You have several options:

  • Recommended:
    If you have a __main__.py in src/discord_trad_bot/ (recommended for package-style projects), run:

    python -m discord_trad_bot
    
  • Directly:
    Or, run the main file directly:

    python src/discord_trad_bot/main.py
    
  • Via entry point (if set up in pyproject.toml):
    If you have a script entry point defined, you can also run:

    discord-trad-bot
    
  • Using the Makefile (shortcut for dev): If you prefer, you can use the provided Makefile command to run the bot in development mode:

    make dev
    

    This is equivalent to running python src/discord_trad_bot/main.py and is handy for quick local testing.

Configuration

Create a .env file with the following variables:

DISCORD_TOKEN=your_discord_bot_token
GOOGLE_TRANSLATE_API_KEY=your_google_translate_api_key

Commands

User Commands

  • !setlang <language_code> — Set your preferred language
  • !mylang — Show your current language setting
  • !languages — List available languages
  • !ping — Test if the bot is working

Admin Commands

  • !settranschannel <#channel> — Set the translation channel
  • !addtranschannel <#channel> — Add a new translation channel
  • !removetranschannel <#channel> — Remove a translation channel
  • !listtranschannels — List all translation channels
  • !setchannellang <#channel> <language_code> — Set the default language for a translation channel
  • !debugdb — Debug command to check database schema and content
  • !transstatus — Show bot status and usage

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.


License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discord_trad_bot-2.0.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

discord_trad_bot-2.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file discord_trad_bot-2.0.1.tar.gz.

File metadata

  • Download URL: discord_trad_bot-2.0.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for discord_trad_bot-2.0.1.tar.gz
Algorithm Hash digest
SHA256 6ecc9398ebe020485aab62067704cc8f397e65973344a0a88e1323fb6434ed0d
MD5 1cea9a2fcddf812703b7974aef72b6c9
BLAKE2b-256 47dd9d12c961a2a4a8ecf147dd6f66af395f96890582d9f78b0f99ac42f6bf07

See more details on using hashes here.

File details

Details for the file discord_trad_bot-2.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for discord_trad_bot-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8bb889432c551054ab7c04f97069bf7f82e1c91a1f17a0f778be3172be574353
MD5 77806a3ff3522c09990b50d78139aa25
BLAKE2b-256 f81fe9931c77604cc154d851a906c7eda7a6502df5291699eb86ca4bbdae5650

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page