Translator application for Discord using DeepL API.
- Python 3.8 or higher is required
- Clone the repo:
$ git clone https://github.com/peunsu/discord-deepl-translator
- Create the virtual environment (optional):
$ python -m venv venv
$ source venv/bin/activate
- Install requirements:
$ pip install -r requirements.txt
- Create a discord bot application.
- Under Privileged Gateway Intents enable Message Content Intent.
- Enable the required bot permissions (administrator).
- Invite your bot to the server with the scopes bot & applications.commands.
- Generate and copy your DeepL API key.
- Create the
.env
file and insert your discord bot token and DeepL API key:
BOT_TOKEN = "your_bot_token"
DEEPL_KEY = "your_deepl_api_key"
- Set up your
config.json
as shown in the example below:
{
"translator": {
# The language into which the text should be translated. Refer to the DeepL API Docs(https://www.deepl.com/docs-api/translate-text).
"target_lang": "KO"
},
"relay": {
# Relay the message from "input" to "output".
# You can set "custom_key" whatever you want.
# The app translates messages sent from "input" channels and sends them to "output" channel.
# When send the translated messages, mention the "role" you set below.
"custom_key": {
"input": [1234567890123456789, 1234567890123456789, 1234567890123456789],
"output": 1234567890123456789,
"role": 1234567890123456789
},
...
},
"messages": {
# Customize your bot messages and the footer icon.
"translate_button": "Translate",
"translate_complete": "Translated the text!",
"original_footer": "Original Message",
"translated_footer": "Translated by DeepL Translator",
"footer_icon_url": "https://i.imgur.com/sg8WDCE.png"
}
- Run the application:
$ python app.py