An advanced LLM-powered conversational simulation framework for Discord
Featuring autonomous action planning, safety filtering, and multi-provider LLM integration for research and controlled testing
Features β’ Installation β’ Configuration β’ Usage β’ Documentation
This project is a SOCIAL EXPERIMENT and EDUCATIONAL TOOL designed to study AI interaction patterns.
- β You are using this strictly in private, controlled test environments
- β You will NOT use this on your main personal account (Risk of Permanent Ban)
- β You will NOT use this to spam, harass, or disrupt public servers
- βοΈ The author assumes NO RESPONSIBILITY for account bans, suspensions, or legal consequences
π΄ USE AT YOUR OWN RISK π΄
|
|
|
|
- Python 3.8 or higher
- pip package manager
- A Discord Bot token
# 1. Clone the repository
git clone https://github.com/HighMark-31/Cognitive-User-Simulation.git
cd Cognitive-User-Simulation
# 2. Install dependencies
pip install -r requirements.txt
# 3. Configure environment
cp .env.example .env
# Edit .env with your credentials
# 4. Run the bot
python discord_bot.pyCreate a .env file in the project root:
# ==========================================
# DISCORD CONFIGURATION
# ==========================================
DISCORD_BOT_TOKEN=your_bot_token_here
# ==========================================
# DATABASE CONFIGURATION
# ==========================================
DATABASE_URL=sqlite+aiosqlite:///discord_bot.db
# ==========================================
# LLM PROVIDER SELECTION
# ==========================================
# Options: glm | openai | gemini
LLM_PROVIDER=glm
# ==========================================
# GLM (Zhipu AI) CONFIGURATION
# ==========================================
GLM_API_KEY=your_glm_api_key_here
GLM_BASE_URL=https://open.bigmodel.cn/api/coding/paas/v4
GLM_MODEL=glm-4.7
# ==========================================
# OPENAI CONFIGURATION
# ==========================================
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_BASE_URL=https://api.openai.com/v1
OPENAI_MODEL=gpt-4o-mini
# ==========================================
# GOOGLE GEMINI CONFIGURATION
# ==========================================
GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-1.5-flash
# ==========================================
# OPTIONAL SETTINGS
# ==========================================
PRIORITY_GUILD_ID=1320998163615846420| Provider | Get API Key | Documentation |
|---|---|---|
| GLM (Zhipu) | open.bigmodel.cn | Docs |
| OpenAI | platform.openai.com | Docs |
| Google Gemini | makersuite.google.com | Docs |
python discord_bot.pyThe bot will automatically:
- π Connect to all servers it's present in
- π¬ Monitor messages in channels and DMs
- π€ Generate contextual responses using the configured LLM
- πΎ Log all interactions to the database
python stats_viewer.pyThe bot autonomously decides what to do next using LLM-based planning:
| Action | Description |
|---|---|
READ |
Read messages from channels to understand context |
REPLY |
Reply to messages in channels |
SEND |
Send new messages to channels |
DM_REPLY |
Reply to direct messages |
DM_SEND |
Send new direct messages |
When a user questions if the bot is an AI:
- Automatically detects suspicion patterns
- Logs the interaction to database
- Generates a natural denial response for EXPERIMENTAL ONLY REASON
- Saves data for analysis
Switch between providers by changing LLM_PROVIDER in .env:
LLM_PROVIDER=glm # Z.ai GLM-4.7
LLM_PROVIDER=openai # GPT-4o-mini
LLM_PROVIDER=gemini # Gemini 1.5 FlashHard-coded regex patterns block:
- Discord invites
- PII (Personal Identifiable Information)
- Scam keywords
- Slurs and toxic content
- Typing Indicators: Simulates realistic typing time based on message length
- Reading Delays: Adds natural reading time before responding
- Presence Management: Rotates status (Online, Idle, DND) and activities
- Sleep Mode: Implements circadian rhythm with nighttime inactivity
βββββββββββββββββββββββββββββββββββββββ
β users β
βββββββββββββββββββββββββββββββββββββββ€
β Information about interacted users β
βββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
β messages β
βββββββββββββββββββββββββββββββββββββββ€
β All received messages β
βββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
β bot_responses β
βββββββββββββββββββββββββββββββββββββββ€
β All bot responses β
βββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
β interactions β
βββββββββββββββββββββββββββββββββββββββ€
β Interaction logs β
βββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
β social_test_logs β
βββββββββββββββββββββββββββββββββββββββ€
β General social test logs β
βββββββββββββββββββββββββββββββββββββββ
All data is saved in discord_bot.db (SQLite).
Modify the bot's personality in discord_bot.py:
mood = 'chill' # Options: chill, energetic, serious, playful
personality = 'sarcastic, direct, ironic, sometimes chaotic'- 2-3 natural, colloquial sentences
- Reference concrete details from context
- Moderate use of slang/abbreviations
- Minimal emojis
- Adapt to channel language (EN/IT)
Examples:
| User Message | Bot Response |
|---|---|
| "Can someone help me?" | "Tell me, what do you need a hand with?" |
| "This code doesn't work" | "Let's talkβwhat part doesn't add up?" |
Bot doesn't respond
- Verify the token in
.env - Check Discord Developer Portal privileges
- Review logs for errors
- Ensure bot has permission to read/send messages
LLM API Error
- Verify the API key is valid
- Check available credits on your LLM account
- Verify the base URL is correct
- Test API connection manually
Bot doesn't save data
- Verify write permissions in the directory
- Check
.envconfiguration - Ensure SQLite is properly installed
- Review
database.pyfor errors
Switching LLM Providers
- Update
LLM_PROVIDERin.env - Ensure the corresponding API key is set
- Restart the bot
- The bot will automatically initialize with the new provider
Cognitive-User-Simulation/
β
βββ .env.example # Example environment variables
β
βββ discord_bot.py # Main bot entry point
βββ LLM_Client.py # LLM provider integration
βββ database.py # Database models and operations
βββ safety_filter.py # Safety and content filtering
βββ stats_viewer.py # Statistics viewer utility
β
βββ requirements.txt # Python dependencies
βββ LICENSE # Project license
βββ README.md # This file
This project is for educational and testing purposes only. Use it responsibly.
See LICENSE file for more details.
For issues or questions:
- Check the logs in the database or
debug.txt - Open an issue in the repository
- Contact the author through GitHub
Made with β€οΈ for educational and research purposes
β Star this repo if you found it interesting! β