This repository contains the source code for TransBot, a real-time message translation bot for Discord. TransBot is an abbreviation for "Translator Bot".
This project is implemented using the Pycord library. This README provides detailed instructions on how to configure and deploy the bot on your local machine.
Before proceeding with the setup, ensure that the following requirements are met:
- A Discord bot
- Python programming language
- Py-cord library
-
Navigate to the Discord Developer Portal, sign in, and select the "New Application" button.
-
Enter the desired bot name and accept the Terms of Service.
-
Provide a description and tags for the bot, then select "Save Changes".
-
Navigate to the "Bot" tab and create a new bot.
-
Reset the bot token and store it in a secure location.
- Clone this repository using the command
git clone https://github.com/yakovexplorer/DiscordTranslateBot.git
. - Change the current working directory to the repository using
cd DiscordTranslateBot
. - Rename the file "env.example" to ".env" and open it for editing.
- Add the values for "DISCORD_TOKEN", and "OPENAI_API_KEY" in the .env file, with your information, as shown below, and save the changes.
DISCORD_TOKEN='YOUR DISCORD BOT TOKEN'
OPENAI_API_KEY='YOUR OPENAI API KEY'
- Install Python by visiting the Python Downloads page and following the provided instructions.
- Open a command prompt or terminal window and enter
pip install py-cord
to install the Py-cord library. - Enter
pip install translatepy
to install the Translatepy library. - Enter
pip install python-dotenv
to install the Python-dotenv library. - Enter
pip install psutil
to install the Psutil library. - Enter
pip install aiofiles
to install the Aiofiles library. - Enter
pip install openai
to install the OpenAI library. - Enter
pip install tiktoken
to install the tiktoken library.
- Navigate to the DiscordTransBot directory on your local machine.
- Execute the command
python3 DiscordBot.py
orpython DiscordBot.py
to start the bot.
-
Return to the Discord Developer Portal and access your bot's OAuth2 page.
-
Use the URL generator tool to create an invitation link for your bot.
-
Copy the generated link and paste it into your web browser to invite your bot to your server.
The following images showcase some of the features provided by this bot:
The source code contained within this repository is licensed under the GNU General Public License v3.0. We strongly recommend reviewing the licensing terms specified in this file.