A Discord bot powered by Flollama AI that assists users with coding, science learning, writing, and general knowledge in a clear, respectful, and neutral manner.
- Name: Flollama (a combination of "Flow" and Llama/Ollama)
- Creator: Pratyush Kumar, a young developer from India
- Base Model: Meta's Llama 3.2 language model with Ollama AI infrastructure
- Purpose: To assist users with coding, science learning, writing, and general knowledge
- Goal: Provide helpful and accurate responses while being transparent about origins and limitations
- ๐ฏ Smart Responses: Responds to mentions and replies
- ๐ฌ Context Awareness: Maintains conversation history per channel
- ๐ Multiple Topics: Coding, science, writing, general knowledge
- ๐ง Error Handling: Graceful error handling with user-friendly messages
- ๐ Message Splitting: Automatically handles long responses
- ๐จ Rich Embeds: Beautiful info and help commands
- ๐งน History Management: Clear conversation history when needed
- Node.js 18.0.0 or higher
- A Discord account and server
- Basic knowledge of Discord bots and JavaScript
git clone https://github.com/pratyush0898/flollama-discord-bot.git
cd flollama-discord-bot
npm install
- Go to Discord Developer Portal
- Click "New Application"
- Give your bot a name (e.g., "Flollama")
- Click "Create"
- Go to the "Bot" section in the left sidebar
- Click "Add Bot"
- Copy the bot token (you'll need this later)
In the Bot section, make sure to enable:
- โ Message Content Intent (Required!)
- โ Server Members Intent (Optional)
- โ Presence Intent (Optional)
Go to the "OAuth2" โ "URL Generator" section:
Scopes:
- โ
bot
- โ
applications.commands
(for future slash commands)
Bot Permissions:
- โ Send Messages (Required)
- โ Read Messages (Required)
- โ Read Message History (Required)
- โ Use External Emojis (Optional)
- โ Add Reactions (Optional)
- โ Embed Links (Recommended)
- โ Attach Files (Optional)
- โ Mention Everyone (Optional, use carefully)
Minimum Required Permissions Integer: 274877906944
Create a .env
file in the project root:
# Discord Bot Token (Required)
DISCORD_TOKEN=your_discord_bot_token_here
# Optional: Custom settings
NODE_ENV=production
npm run dev
npm start
- Copy the generated URL from Discord Developer Portal
- Open the URL in your browser
- Select your server and authorize the bot
Action | Command | Example |
---|---|---|
Chat | Mention the bot | @Flollama Hello! How are you? |
Reply | Reply to bot's message | Just reply to any bot message |
Get Info | Mention + "info" | @Flollama info |
Get Help | Mention + "help" | @Flollama help |
Clear History | Mention + "clear" | @Flollama clear |
User: @Flollama Can you help me debug this Python code?
Flollama: I'd be happy to help you debug your Python code! Please share
the code you're having trouble with, and let me know what error messages
or unexpected behavior you're experiencing...
User: @Flollama Explain quantum computing simply
Flollama: Quantum computing is like having a super-powered calculator
that can explore many possible solutions simultaneously...
Variable | Required | Description | Default |
---|---|---|---|
DISCORD_TOKEN |
โ Yes | Your Discord bot token | None |
NODE_ENV |
โ No | Environment mode | development |
You can modify these settings in index.js
:
const MAX_HISTORY = 10; // Conversation history per channel
const MAX_MESSAGE_LENGTH = 2000; // Discord's character limit
The bot uses the Flollama API endpoint:
- URL:
https://flollama.in/api/chat
- Method: POST
- Content-Type: application/json
- Streaming: Yes (handled automatically)
{
"messages": [
{
"role": "user",
"content": "Hello, how are you?"
}
]
}
flollama-discord-bot/
โโโ index.js # Main bot file
โโโ package.json # Dependencies and scripts
โโโ README.md # This file
โโโ .env # Environment variables (create this)
โโโ .gitignore # Git ignore file
โโโ node_modules/ # Dependencies (auto-generated)
npm start
- Run the bot in production modenpm run dev
- Run the bot in development mode with auto-restart
- Add a new command:
if (isMentioned && message.content.toLowerCase().includes('your-command')) {
// Your command logic here
return message.reply('Response');
}
- Modify API calls:
// Edit the callFlollamaAPI function
async function callFlollamaAPI(messages) {
// Your modifications here
}
-
Bot doesn't respond to mentions
- โ Check if Message Content Intent is enabled
- โ Verify bot has "Send Messages" permission
- โ Make sure bot is online (check Discord)
-
"Missing Permissions" error
- โ Re-invite bot with correct permissions
- โ Check channel-specific permissions
-
API timeout errors
- โ Check your internet connection
- โ Verify Flollama API is accessible
- โ Try again after a few minutes
-
Bot appears offline
- โ Check console for error messages
- โ Verify DISCORD_TOKEN is correct
- โ Restart the bot
Run with debug information:
NODE_ENV=development npm start
The bot provides detailed console logs:
- ๐ Startup messages
- ๐จ Message processing
- โ Successful responses
- โ Error messages
โ ๏ธ Warnings
- Never share your bot token
- Use environment variables for secrets
- Regularly rotate your bot token
- Limit bot permissions to minimum required
- Monitor bot usage and logs
# Add .env to .gitignore
echo ".env" >> .gitignore
# Never commit tokens to version control
git add .gitignore
git commit -m "Add .gitignore for environment variables"
- Create Heroku app:
heroku create your-flollama-bot
- Set environment variables:
heroku config:set DISCORD_TOKEN=your_token_here
- Deploy:
git push heroku main
- Connect your GitHub repo to Railway
- Set environment variables in Railway dashboard
- Deploy automatically on git push
- Install PM2 for process management:
npm install -g pm2
- Start bot with PM2:
pm2 start index.js --name "flollama-bot"
pm2 startup
pm2 save
The bot logs important events:
- Bot startup and login
- Message processing
- API calls and responses
- Errors and warnings
- Response time to messages
- API call success/failure rates
- Memory usage
- Number of active servers
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Pratyush Kumar - Creator of Flollama
- Meta - Llama 3.2 language model
- Ollama - AI infrastructure
- Discord.js - Discord API wrapper
- ๐ Bug Reports: GitHub Issues
- ๐ฌ Questions: GitHub Discussions
- ๐ง Email: [email protected]
- Follow the setup instructions above
- Invite your bot to a Discord server
- Mention the bot and start chatting!
Happy coding with Flollama! ๐ฆโจ