A Discord bot powered by OpenRouter AI that can respond to mentions, follow up on conversations, and occasionally chime in randomly. The bot stores message history in SQLite and uses LLM models for intelligent responses.
- AI-powered responses using OpenRouter API
- Message history tracking in SQLite database
- Multiple response triggers:
- Direct mentions
- Follow-up conversations (30% chance)
- Random interventions (1/17 chance)
- Image recognition support
- Custom emoji replacement
- Message context from chat history
- Bun runtime
- Discord Bot Token
- OpenRouter API Key
bun installCopy the example environment file:
cp .env.example .envFill in the required values in .env:
DISCORD_TOKEN=your_discord_bot_token_here
OPENROUTER_TOKEN=your_openrouter_api_key_here
ACTIVITY=your_bot_status_message
MODEL=your_preferred_model (e.g., anthropic/claude-3.5-sonnet)
IMAGE_RECOGNITION_MODEL=your_image_model (e.g., anthropic/claude-3.5-sonnet)Getting tokens:
- Discord Token: Create a bot at Discord Developer Portal
- Enable these intents: Guild Messages, Message Content, Guilds
- OpenRouter Token: Sign up at OpenRouter
Copy and customize the emoji mappings:
cp emojis.example.ts emojis.tsEdit emojis.ts to map text emoji codes to Discord emoji IDs:
export const Emojis = {
":NOOO:": "<:NOOO:1351971548436627528>",
":HAPPY:": "<:HAPPY:your_emoji_id_here>",
// Add more custom emojis
}Copy and customize the AI system prompt:
cp system_prompt.example.ts system_prompt.tsEdit system_prompt.ts to define your bot's personality and behavior:
export const SystemPrompt = `Your bot's personality and instructions here`;
export const ImageDescriptionPrompt = `Instructions for image analysis`;bun run index.tsConsider using a process manager like PM2:
pm2 start "bun run index.ts" --name discord-botThe bot automatically creates a SQLite database (messages.sqlite3) on first run with the following schema:
message_id- Primary keychannel_id- Discord channel IDcontent- Message contentattachment- Attachment data (currently unused)author_id- User IDcreated_timestamp- Message timestampcontent_length- Length of message
When inviting the bot, ensure these permissions are enabled:
- Read Messages/View Channels
- Send Messages
- Send Messages in Threads
- Read Message History
- Use External Emojis
- Add Reactions
This project is MIT Licensed