A high-performance Discord bot written in C++ that delivers memes directly to your Discord server. Fast, reliable, and customizable.
- Fast Response Times: Written in C++ for optimal performance
- Random Memes: Fetch memes from multiple popular subreddits
- Subreddit Selection: Request memes from specific subreddits
- Beautiful Embeds: Clean presentation with title, image, and source information
- SFW Filter: Automatically filters NSFW content
- Cache System: Maintains a local cache of memes for quick responses
- Auto-Refresh: Periodically refreshes the meme cache in the background
- Slash Commands: Modern Discord interaction using slash commands
- C++ Compiler (GCC 8+ or equivalent)
- CMake 3.10+
- D++ Discord library
- nlohmann/json library
- cpr HTTP library
- Clone the repository:
git clone https://github.com/yourusername/discord-meme-bot.git
cd discord-meme-bot- Configure the bot:
cp config.example.json config.json
# Edit config.json with your Discord and Reddit credentials- Build the project:
chmod +x build.sh
./build.sh- Run the bot:
./build/meme_botFor detailed installation instructions, see the Installation Guide.
Once the bot is running and has been added to your Discord server, you can use the following commands:
/meme- Get a random meme from any of the configured subreddits/meme subreddit:programmerhumor- Get a meme specifically from r/programmerhumor (or any other subreddit in your config)
/help— Show a private command menu./coinflip— Flip a coin and share heads or tails with the channel./roll— Roll a six-sided die./roll sides:20— Roll a custom die with 2–100 sides./8ball question:Will we win tonight?— Get a playful answer from the meme oracle.
The fun commands work independently of the Reddit meme cache. Restart the bot with the updated code to register them; Discord may take time to show new global commands.
- D++ - Discord API wrapper for C++
- nlohmann/json - JSON library for C++
- cpr - C++ Requests library (wrapper around libcurl)
- Architecture: Multi-threaded design with background cache refresh
- API Integrations:
- Discord API (via D++ library)
- Reddit API (OAuth2)
- Data Structures:
- Meme caching system with mutex locks for thread safety
- Configuration management using JSON
- Performance: Minimal memory footprint and CPU usage
The config.json file contains the following fields:
{
"discord_token": "YOUR_DISCORD_BOT_TOKEN",
"reddit_client_id": "YOUR_REDDIT_CLIENT_ID",
"reddit_client_secret": "YOUR_REDDIT_CLIENT_SECRET",
"reddit_username": "YOUR_REDDIT_USERNAME",
"reddit_password": "YOUR_REDDIT_PASSWORD",
"meme_subreddits": [
"memes",
"dankmemes",
"wholesomememes",
"programmerhumor",
"memeeconomy"
]
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some 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.
- D++ for providing an excellent Discord library
- Reddit API for meme content