English | 简体中文
A Discord bot that integrates with x.ai's API to provide an interactive AI assistant with multiple conversation modes, user-specific conversation history, and channel auto-response capabilities.
- Multiple AI Modes: Switch between different personalities and use cases like general chatting, learning assistant, coding helper, etc.
- Conversation History: Maintains separate conversation histories for each user across different chats
- Channel Auto-Response: Configure specific channels where the bot will respond to all messages without needing to be pinged
- Simple Command System: Easy-to-use slash commands for all interactions
- User-Friendly Interface: Clean embeds and interactive components for a polished user experience
- Python 3.12 (Discord.py v2.3.2 does not support Python 3.13)
- A Discord bot token (create one at Discord Developer Portal)
- An x.ai API key (sign up at x.ai)
-
Clone this repository:
git clone https://github.com/Jinomee/jBot.git cd jBot -
Install the required dependencies:
pip install -r requirements.txt
-
Download the latest release from the Releases page.
-
Extract the ZIP file to your desired location.
-
Open a terminal or command prompt and navigate to the extracted directory:
cd path/to/extracted/jBot -
Install the required dependencies:
pip install -r requirements.txt -
Configure your environment variables in the
.envfile:# Discord Bot Token DISCORD_TOKEN=your_discord_bot_token_here # AI API Configuration AI_API_URL=https://api.x.ai/v1 XAI_API_KEY=your_xai_api_key_here # AI Model Selection AI_MODEL=grok-3-mini-beta -
Run the bot:
python bot.py
- Go to the Discord Developer Portal
- Select your application and go to the "OAuth2" → "URL Generator" tab
- Select the following scopes:
botapplications.commands
- Select the following bot permissions:
Send MessagesSend Messages in ThreadsEmbed LinksAttach FilesRead Message HistoryUse Slash CommandsUse Embedded Activities
- Copy and open the generated URL to add the bot to your server
The bot responds to:
- Direct messages
- Mentions (@BotName)
- Messages in enabled auto-reply channels
/help- Displays all available commands/mode- View and change the AI assistant mode/newchat- Start a new conversation with the AI/chathistory- View and select from your previous conversations/settings- Configure the AI assistant settings/clear- Clear your current conversation history/autoreply- Toggle auto-responses in a specific channel (requires Manage Channels permission)
- Use the command:
/autoreply channel:#channel-name - The bot will now respond to all messages in that channel without needing to be pinged
- To disable auto-replies in a channel:
/autoreply channel:#channel-name enable:False
The bot comes with several pre-configured AI modes:
- General Chatting - Casual conversation with the AI assistant
- Learning Assistant - Help with studying and learning new concepts
- Coding Helper - Assistance with programming and coding tasks
- Creative Writing - Help with creative writing and content creation
- Language Tutor - Practice and learn new languages
- Personal Coach - Get motivation and guidance for personal growth
You can easily add more modes by editing the DEFAULT_AI_MODES dictionary in the config.py file.
Edit the config.py file to add new modes:
"your_mode_id": {
"name": "Your Mode Name",
"description": "Description of what this mode does",
"system_prompt": "System prompt that defines the AI's behavior in this mode"
}Various bot settings can be configured in the config.py file:
BOT_SETTINGS = {
"default_mode": "general_chatting",
"max_tokens": 500,
"user_data_file": "user_data.json",
"command_cooldown": 3 # seconds
}- Slash Commands Not Appearing: Try inviting the bot to your server again using the URL with both
botandapplications.commandsscopes. - Bot Not Responding: Check that your Discord token is correct in the
.envfile. - API Errors: Verify your x.ai API key and make sure you have sufficient API credits.
- Permission Issues: Ensure the bot has proper permissions in your Discord server.
This project is licensed under the MIT License - see the LICENSE file for details.
- Uses x.ai's API for AI capabilities
- Built with discord.py library