Luffy Bot
customizable discord translation bot & more! easy to setup and configure
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
Luffy Bot is a versatile and customizable Discord bot designed to enhance your server's communication experience. Whether you need seamless language translation, efficient message relay, or robust tools, Luffy Bot has you covered and is easy to setup and configure to your specific needs.
If you intend to use this project you will need your own google translation or libre
translation API key. The project supports use of both apis as well, it will default to using google translate until it reaches a monthly character limit of 500,000 (googles free tier limit) and then it will switch to using libre translate for the remainder of the month. Alternatively you can opt to just use one or the other.
Features:
-
Synchronized Multilingual Chats
- Synchronize chat content across users, with each message displayed in the user's preferred language. This allows for seamless, multilingual conversations where every user sees messages in their own language, enhancing the inclusivity and accessibility of discussions.
-
Automatic Translation & Relay
- Effortlessly translate messages into multiple languages and relay them to designated channels, fostering global communication within your server.
-
Reaction Based Translation
- Enable users to trigger automatic translations by reacting with flag emojis, breaking down language barriers with a simple gesture.
-
Reaction Roles
- Admins can set up messages with associated roles. When users react to these messages, the bot assigns them the specified roles, streamlining role assignment and enhancing user interaction within the server.
-
Keyword Triggered Responses
- Enable the bot to listen for specific phrases or words within messages and respond accordingly, enhancing user engagement and interactivity within your server.
-
Rate Limit
- Implement intelligent rate limiting to ensure fair usage of translation services, maintaining service availability while preventing abuse.
-
Slash Commands
- Empower developers, administrators, and users alike with a range of utility and fun commands, enhancing server management and interaction.
-
Logging
- Gain insights into server activities with comprehensive logging functionality, capturing key events and interactions for administrative review.
Explore the documentation to unlock the full potential of Luffy Bot and elevate your Discord server to new heights of communication efficiency.
Screenshots
Built With
Getting Started
Prerequisites
-
Download and install node.js
// run this line inside the terminal choco install nodejs-lts // or visit: https://nodejs.org/en/download
-
Verify node version [v20.12.2+]
node -v
-
Verify npm version [v10.7.0+]
npm -v
-
Install latest npm [optional]
npm install npm@latest -g
Installation
-
Clone the repo
git clone https://github.com/DevTruce/Luffy-Bot.git
-
Install NPM packages
npm install
-
Deploy Commands
npm run build
-
Deploy App
npm start
Setup Guide
Important: Before following the setup guide please be sure to have the following ready!
- Discord server
- Discord bot setup inside of Discord Developer Portal
- Google Translate/LibreTranslate API Key
Config File
1. Create a file named "config.json" in the project root
2. Copy/paste the text below, fill in the information and change any values needed.
{
"avatarSet": false,
"bot": {
"appID": "",
"token": ""
},
"pokemonApiUrl": "https://pokeapi.co/api/v2/pokemon/",
"giphyApiUrl": "https://api.giphy.com/v1",
"giphyApiKey": "",
"apiNinjasFactUrl": "https://api.api-ninjas.com/v1/facts",
"apiNinjasDadJokeUrl": "https://api.api-ninjas.com/v1/dadjokes",
"apiNinjasKey": "",
"translationService": {
"useLibreTranslate": true,
"useGoogleTranslate": true,
"libreTranslate": {
"apiUrlDetect": "https://libretranslate.com/detect",
"apiUrl": "https://libretranslate.com/translate",
"apiKey": ""
},
"googleTranslate": {
"apiUrlDetect": "https://translation.googleapis.com/language/translate/v2/detect?key=",
"apiUrl": "https://translation.googleapis.com/language/translate/v2?key=",
"apiKey": ""
}
},
"discord": {
"guildID": "",
"adminUserIDs": [
""
],
"languageSections": {
"english": {
"language": "English",
"languageCode": "en",
"roleID": "",
"announcementChannelID": "",
"chatChannelID": ""
},
"spanish": {
"language": "Spanish",
"languageCode": "es",
"roleID": "",
"announcementChannelID": "",
"chatChannelID": ""
},
"swedish": {
"language": "Swedish",
"languageCode": "sv",
"roleID": "",
"announcementChannelID": "",
"chatChannelID": ""
},
"arabic": {
"language": "Arabic",
"languageCode": "ar",
"roleID": "",
"announcementChannelID": "",
"chatChannelID": ""
}
},
"reactionTranslateWhitelistChannelIDs": [
""
],
"devUserID": ""
},
"links": {
"fullGame": "",
"patch": "",
"gameStatus": ""
},
"paypalEmails": {
"devtruce": "",
"warner": ""
},
"lastResetMonth": 1,
"monthlyCharacterLimit": 500000,
"totalCharactersSent": 0,
"minuteRequestLimit": 120,
"requestThisMinute": 1,
"lastResetMinute": 1
}
3. Create a file named "reactionRoles.json" in the project root and leave it blank.
How To Setup Automatic Translate and Relay Announcements
1. Create language specific roles inside of discord
2. Create languge specific announcement chanels inside of discord
3. Navigate to "config.json" and within the languageSection update the "roleID" & "announcementChannelID" for each language
"english": {
"language": "English",
"languageCode": "en",
"roleID": "id_here",
"announcementChannelID": "id_here",
"chatChannelID": ""
},4. Navigate to "src/events/messageCreate.js" & find the function named autoTranslateAndRelayAnnouncement
If while following the steps above you decided to add/remove/change the languages then please be sure to correctly call the function here to support any language changes you may have made.
await autoTranslateAndRelayAnnouncement(
message,
languageSections.english.announcementChannelID, // primary announcement channel
[
// send to spanish announcements channel
{
channelID: languageSections.spanish.announcementChannelID,
language: languageSections.spanish.language,
languageCode: languageSections.spanish.languageCode,
roleID: languageSections.spanish.roleID,
},
// send to swedish announcements channel
{
channelID: languageSections.swedish.announcementChannelID,
language: languageSections.swedish.language,
languageCode: languageSections.swedish.languageCode,
roleID: languageSections.swedish.roleID,
},
// send to arabic announcements channel
{
channelID: languageSections.arabic.announcementChannelID,
language: languageSections.arabic.language,
languageCode: languageSections.arabic.languageCode,
roleID: languageSections.arabic.roleID,
},
// Add more language sections as needed
],
message.author
);How To Setup Automatic Translate and Relay Messages
1. Create languge specific chat chanels inside of discord
2. Navigate to "config.json" and within the languageSection update the "chatChannelID" for each language
"english": {
"language": "English",
"languageCode": "en",
"roleID": "",
"announcementChannelID": "",
"chatChannelID": "id_here"
},3. Navigate to "src/events/messageCreate.js" & find the functions named autoTranslateAndRelayMessage
If while following the steps above you decided to add/remove/change the languages then please be sure to correctly call the functions here to support any language changes you may have made. This function is called multiple times for different channels so be sure to review closely!
////// English -> Others
await autoTranslateAndRelayMessage(
message,
languageSections.english.chatChannelID, // source
languageSections.english.language, // source
languageSections.english.languageCode, // source
[
{
// send to spanish chat channel
channelID: languageSections.spanish.chatChannelID,
language: languageSections.spanish.language,
languageCode: languageSections.spanish.languageCode,
},
{
// send to swedish chat channel
channelID: languageSections.swedish.chatChannelID,
language: languageSections.swedish.language,
languageCode: languageSections.swedish.languageCode,
},
{
// send to arabic chat channel
channelID: languageSections.arabic.chatChannelID,
language: languageSections.arabic.language,
languageCode: languageSections.arabic.languageCode,
},
// Add more language sections as needed
],
message.author
);
////// Spanish -> Others
await autoTranslateAndRelayMessage(
message,
languageSections.spanish.chatChannelID,
languageSections.spanish.language,
languageSections.spanish.languageCode,
[
{
channelID: languageSections.english.chatChannelID,
language: languageSections.english.language,
languageCode: languageSections.english.languageCode,
},
{
channelID: languageSections.swedish.chatChannelID,
language: languageSections.swedish.language,
languageCode: languageSections.swedish.languageCode,
},
{
channelID: languageSections.arabic.chatChannelID,
language: languageSections.arabic.language,
languageCode: languageSections.arabic.languageCode,
},
// Add more language sections as needed
],
message.author
);How To Setup Reaction Translations
1. Navigate to "config.json" and look for "reactionTranslateWhitelistChannelIDs"
this is where you will add channel ids or category ids for areas you will allow reaction translations to work. Example: our server only allows for use of reaction translations inside of tickets, everything else is handled by autoTranslateAndRelayAnnouncement and autoTranslateAndRelayMessage.
"reactionTranslateWhitelistChannelIDs": ["allowed_channel_id_here", "allowed_channel_id_here"]Reaction Translation Language Support
If you are using Google Translate OR LibreTranslate API then you only need to follow step 1. If you are using LibreTranslate and are self hosting then you must follow all 3 steps
1. Navigate to "src/functions/flagToLanguage.js
//this is where you can add or remove languages you want to support.
const flagToLanguage = {
// "emoji" : "language"
"🇺🇸": "en", // english
};
// List of All Emoji Flag ISO: https://apps.timwhitlock.info/emoji/tables/iso31662. Navigate to your LibreTranslate Terminal and run the following line
nano /app/data/env.sh3. Find the following line inside env.sh and add or remove languages
export LT_LANGUAGE_MODELS=en,fr,es,pt,ru,de,arHow To Setup Keyword Triggers
Setting up keyword triggers is very simple, all you need to do is call the function and pass the message, phrase you are looking for, response you want to give. Below is an example of how you would setup a keyword trigger.
1. Navigate to src/events/messageCreate.js and add the code within execute function.
keywordTriggers(message, "how to", "user asked how to do something");Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
How to Contribute
- Fork the Project: Fork the repository to your own GitHub account.
- Create Your Feature Branch: Create a new branch for your feature or bug fix.
- Make Changes: Make your changes to the codebase. Be sure to follow the project's coding conventions and guidelines.
- Test Your Changes: Test your changes thoroughly to ensure they work as expected.
- Commit Your Changes: Commit your changes with descriptive commit messages.
- Push to Your Branch: Push your changes to your forked repository.
- Submit a Pull Request: Submit a pull request from your branch to the main repository's main branch.
What Can I Contribute?
- Bug Fixes: If you encounter a bug, feel free to investigate and submit a fix.
- Feature Requests: Have an idea for a new feature? Submit a feature request or, better yet, implement it yourself and submit a pull request.
- Documentation: Help improve the project's documentation by fixing typos, clarifying instructions, or adding new sections.
- Code Refactoring: If you notice areas of the code that could be improved for readability or performance, refactor them and submit a pull request.
- Testing: Expand the test coverage of the project by writing new tests or improving existing ones.
Get Started
Not sure where to start? Check out the issues section for open issues or feature requests.
Thank you for considering contributing to the Luffy Bot project!
Contact
Email: DevTruce@Outlook.com
Discord: xzypher.
License
Distributed under the MIT License. See LICENSE.txt for more information.











