An AI-powered Discord music bot with personality and emotions
Created by Arya Dasgupta
MikuChan is not just another Discord bot - she's a soft, emotionally complex AI companion who can play music from YouTube and engage in meaningful conversations. She remembers your choices, knows server members, and has her own unique personality.
- ๐ค AI Chat System - Chat with MikuChan using Google's Gemini AI
- ๐ต YouTube Music Player - Play, pause, resume, and control music
- ๐ง Memory & Personality - Knows server members and key infomation about them
- ๐ Emotional Intelligence - Responds with genuine emotions and personality
- ๐๏ธ Voice Controls - Volume control, queue management
- ๐ง Debug Tools - Built-in system diagnostics
- Python 3.8+ - Core programming language
- discord.py - Discord API wrapper
- Google Gemini AI - Advanced conversational AI
- yt-dlp - YouTube audio extraction
- FFmpeg - Audio processing
-
Install Python 3.8 or higher:
- Go to python.org
- Download the latest Python version
โ ๏ธ IMPORTANT: Check "Add Python to PATH" during installation- Verify installation: Open Command Prompt and run
python --version
-
Install FFmpeg:
- Go to ffmpeg.org
- Download FFmpeg for Windows
- Extract to
C:\ffmpeg\ - Add
C:\ffmpeg\binto your system PATH - Verify: Run
ffmpeg -versionin Command Prompt
-
Install Python 3.8+:
# Ubuntu/Debian sudo apt update sudo apt install python3 python3-pip python3-venv # CentOS/RHEL/Fedora sudo dnf install python3 python3-pip # Arch Linux sudo pacman -S python python-pip
-
Install FFmpeg:
# Ubuntu/Debian sudo apt install ffmpeg # CentOS/RHEL/Fedora sudo dnf install ffmpeg # Arch Linux sudo pacman -S ffmpeg
-
Install audio dependencies:
# Ubuntu/Debian sudo apt install pulseaudio alsa-utils # For headless servers sudo apt install pulseaudio-utils
Option A: Git Clone (Recommended)
git clone https://github.com/AryaXDG/MikuChanBot.git
cd MikuChanBotOption B: Download ZIP
- Go to the GitHub repository
- Click "Code" โ "Download ZIP"
- Extract the ZIP file
- Open terminal/command prompt in the extracted folder
Windows:
python -m venv mikuchan_env
mikuchan_env\Scripts\activateLinux:
python3 -m venv mikuchan_env
source mikuchan_env/bin/activatepip install -r requirements.txtIf you get permission errors on Linux, try:
pip install --user -r requirements.txt-
Go to Discord Developer Portal:
- Visit discord.com/developers/applications
- Click "New Application"
- Give it a name (e.g., "MikuChan")
-
Create Bot:
- Go to "Bot" section in left sidebar
- Click "Add Bot"
- Under "Token" section, click "Copy" to copy your bot token
โ ๏ธ Keep this token SECRET!
-
Set Bot Permissions:
- Under "Privileged Gateway Intents":
- โ Enable "Message Content Intent"
- Under "Bot Permissions":
- โ Send Messages
- โ Connect
- โ Speak
- โ Use Voice Activity
- Under "Privileged Gateway Intents":
-
Go to Google AI Studio:
- Visit makersuite.google.com/app/apikey
- Sign in with your Google account
-
Create API Key:
- Click "Create API Key"
- Choose "Create API key in new project" (or select existing project)
- Copy the generated API key
โ ๏ธ Keep this key SECRET!
Create a file named .env in the bot folder:
Windows: Use Notepad or any text editor Linux: Use nano, vim, or any text editor
# Windows
notepad .env
# Linux
nano .envPut this in your .env file:
DISCORD_TOKEN=your_discord_bot_token_here
GEMINI_API_KEY=your_gemini_api_key_hereReplace the placeholder text with your actual tokens!
Edit config.py to:
- Add server members to
SERVER_MEMBERS - Modify
MIKU_PERSONALITYto change bot behavior - Adjust
CHAT_CONFIGfor response settings
Windows:
python bot.pyLinux:
python3 bot.py๐ Starting MikuChan Bot...
๐ต Music system ready
๐ค AI chat system will initialize on ready
==================================================
โ
MikuChan is online as MikuChan#1234
๐ค Initializing AI chat system...
โ
AI chat system ready!
Use screen or tmux:
# Using screen
screen -S mikuchan
python3 bot.py
# Press Ctrl+A, then D to detach
# To reattach later
screen -r mikuchan- Go back to Discord Developer Portal
- Select your application
- Go to "OAuth2" โ "URL Generator"
- Scopes: Check
bot - Bot Permissions: Select:
- Send Messages
- Connect
- Speak
- Use Voice Activity
- Read Message History
- Copy the generated URL
- Paste the URL in your browser
- Select your Discord server
- Click "Authorize"
- Complete the captcha
| Command | Aliases | Description | Example |
|---|---|---|---|
!chat <message> |
!c, !talk |
Chat with MikuChan AI | !chat How are you feeling? |
!aistats |
- | Show AI system statistics | !aistats |
| Command | Description | Example |
|---|---|---|
!join |
Join your voice channel | !join |
!play <song> |
Play music from YouTube | !play Never Gonna Give You Up |
!pause |
Pause current song | !pause |
!resume |
Resume paused song | !resume |
!stop |
Stop current song | !stop |
!leave |
Leave voice channel | !leave |
!volume <0-100> |
Change volume | !volume 50 |
| Command | Description |
|---|---|
!debug |
Show system information |
!test |
Test FFmpeg installation |
!filetest |
Test latest downloaded file |
- Direct mentions: You can also mention MikuChan directly:
@MikuChan how are you? - Personality: She has moods, emotions, and will react differently based on context
- Server members: Configure known members in
config.pyfor personalized interactions
"ModuleNotFoundError"
# Make sure virtual environment is activated
# Windows: mikuchan_env\Scripts\activate
# Linux: source mikuchan_env/bin/activate
# Reinstall dependencies
pip install -r requirements.txt"Discord Token Invalid"
- Double-check your token in
.envfile - Make sure there are no extra spaces
- Regenerate token in Discord Developer Portal if needed
"FFmpeg not found"
- Verify FFmpeg installation:
ffmpeg -version - Check PATH environment variable
- Restart terminal after installing FFmpeg
"Audio not playing"
- Use
!debugcommand to check system status - Try
!testto verify FFmpeg - Ensure bot has voice permissions in Discord
"AI not responding"
- Check Gemini API key in
.envfile - Verify API key hasn't exceeded quota
- Use
!aistatsto check AI system status
# Install additional audio packages
sudo apt install pulseaudio-utils alsa-utils
# Start PulseAudio
pulseaudio --start
# Check audio devices
aplay -l- Check the console output for detailed error messages
- Use
!debugcommand for system diagnostics - Enable verbose debugging in
config.py
mikuchan-bot/
โโโ bot.py # Main bot file
โโโ ai_chat.py # AI chat system
โโโ config.py # Configuration and personalities
โโโ requirements.txt # Dependencies
โโโ .env # Environment variables (you create this)
โโโ downloads/ # Downloaded music files
โโโ README.md # This file
- Never share your
.envfile - it contains secret tokens - Never commit
.envto git - add it to.gitignore - Regenerate tokens if compromised
- Use a dedicated Google account for Gemini API
- Monitor API usage to avoid unexpected charges
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Arya Dasgupta
- GitHub: AryaXDG
- Discord: [aryaxdg]
Thanks for trying out my bot :)