A Discord bot powered by Google's Generative AI (GenAI) designed to provide conversational AI capabilities, automated welcome/goodbye messages, and utility commands within your Discord server.
- Conversational AI: Engage in conversations by mentioning the bot or replying to its messages. It uses reply chains for context.
- AI-Powered Welcome Messages: Automatically generates and sends a unique welcome message when a new member joins the server.
- AI-Powered Goodbye Messages: Automatically generates and sends a goodbye message when a member leaves the server.
- Slash Commands
- Configurable AI Models: Choose different Google AI models for different tasks (general chat, welcome/goodbye messages).
- Model Fallback: Automatically attempts to use a secondary AI model if the primary one fails.
- (Hidden) Timeout Command: Includes a mechanism for timing out users (triggered via specific bot replies - see code for details).
- Python 3.10+
- Discord Bot Token: You need to create a Discord Application and get a bot token. See the Discord Developer Portal.
- Required Intents: Ensure your bot has the following Privileged Gateway Intents enabled in the Developer Portal:
Server Members Intent(Required foron_member_join/on_member_removeand fetching members)Message Content Intent(Required for reading message content for AI context and commands)
- Required Intents: Ensure your bot has the following Privileged Gateway Intents enabled in the Developer Portal:
- Google AI Studio API Key: You need an API key from Google AI Studio.
-
Clone the Repository:
git clone https://github.com/Sorro123/DiscordBot.git
-
Configure API Keys (
variables/keys.json): Renamekeys.EXAMPLE.jsontokeys.jsoninside thevariablesdirectory with your API keys:{ "Bot": { "client_key":"YOUR_DISCORD_BOT_TOKEN" }, "ai_studio_key": "YOUR_GOOGLE_AI_STUDIO_API_KEY" } -
Configure Prompts (
variables/prompts.json): Renameprompts.EXAMPLE.jsontoprompts.jsoninside thevariablesdirectory. This defines the instructions given to the AI. Adjust the prompts to shape the bot's personality and responses.- An example system prompt is provided, either replace all of the text between backticks ` with the appropriate value or write your own.
-
Configure General Settings (
variables/general.json): General variables are controlled by a file namedgeneral.jsoninside thevariablesdirectory.- Make sure the model names listed in
"ai_studio"are valid models accessible via your API key. Check the Google AI documentation for available models. - Make sure to change
"owner_id"to YOUR discord ID.
- Make sure the model names listed in
-
Configure modules (
variables/modules.json): Modules are controlled by a file namedmodules.jsoninside thevariablesdirectory.- Set the value of any module you don't want to use to
false
- Set the value of any module you don't want to use to
-
Install and start the bot:
- Windows:
Run
UpdateAndStart.batin the terminal or double-click the file. This script will handle dependency installation/updates and start the bot.UpdateAndStart_Windows.bat
- Linux:
Make the
./UpdateAndStart_Linux.shscript executable and then run it. This script will handle dependency installation/updates and start the bot.chmod +x run.sh ./UpdateAndStart_Linux.sh
- Windows:
Run
To run the bot after the initial setup:
-
Auto Update:
- Windows: Execute
UpdateAndStart_Windows.bat. This script auto-pulls updates from the repository and then launches the bot.UpdateAndStart_Windows.bat
- Linux: Make
UpdateAndStart_Linux.shexecutable and then run it. This script auto-pulls updates from the repository and then launches the bot.chmod +x UpdateAndStart_Linux.sh ./UpdateAndStart_Linux.sh
- Windows: Execute
-
No Update:
-
Windows: Execute
Start_Windows.bat.Start_Windows.bat
-
Linux: Execute
Start_Linux.sh../Start_Linux.sh
-
- Chat: Mention the bot (
@YourBotName), use its display name or reply directly to one of its messages to start or continue a conversation. - Commands: Use the slash commands registered with Discord:
/help: Get help information.
- Welcome/Goodbye: These messages are triggered automatically when members join or leave the server, provided the bot has permission to see these events and post in the configured system channel.
-
Create a brand new discord bot
-
Adding settings: Open the
keys.json,prompts.jsonandmodules.jsonfiles in thevariablesfolder and duplicate the"Bot":{}field in each, rename the new duplicated"Bot"to a different name, ensuring it is the same across all 3 files, and re-configure the new fields as desired, similar to how it is done in steps 2-5 of Setup & Installation, for exampl:{ "Bot": { "client_key":"YOUR_DISCORD_BOT_TOKEN" }, "Bot2": { "client_key":"YOUR_DISCORD_BOT_TOKEN" }, "ai_studio_key": "YOUR_GOOGLE_AI_STUDIO_API_KEY" } -
Activating new bot: Open the
generalfile in thevarialesfolder and add the new name to the"Bots"array, for example:"Bots":["Bot", "Bot2"],
Contributions are welcome! If you have suggestions for improvements or find bugs, please feel free to open an issue or submit a pull request.
DiscordBot by UrBoiTom_ is licensed under CC BY-NC-SA 4.0 License - see the LICENSE.md file for details.