NI
ninasproule/madlibs_bot
A discord bot for playing, and creating your own madlibs that others can play!
Discord MadLibs Bot
A discord bot for playing, and creating your own madlibs that others can play!
Features
- Play MadLibs: Choose from available templates or get a random one
- Create Custom Templates: Make your own MadLib stories for others to enjoy
- Template Management: Browse all available MadLibs with paged lists
- Interactive Gameplay: Bot guides players through each word prompt
- Persistent Storage: All custom templates are saved and persist between bot restarts
- User-Friendly Interface: Rich Discord embeds for better user experience
Commands
| Command | Description | Usage |
|---|---|---|
&play [title] |
Play a MadLib (random if no title specified) | &play or &play wedding vows |
&new |
Create a new MadLib template | &new |
&list |
View all available MadLib titles | &list |
&cancel |
Cancel any running MadLib operations | &cancel |
&help |
Display help message with all commands | &help |
Installation & Setup
Prerequisites
- Python 3.8 or higher
- A Discord Bot Token
Step 1: Clone the Repository
git clone https://github.com/ninasproule/madlibs_bot.git
cd madlibs_botStep 2: Install Dependencies
pip install -r requirements.txtStep 3: Set Up Environment Variables
-
Create a
.envfile in the project root: -
Add your Discord bot token to the
.envfile:
DISCORD_TOKEN=your_bot_token_here
Step 4: Get a Discord Bot Token
- Go to the Discord Developer Portal
- Create a new application
- Go to the "Bot" section
- Create a bot and copy the token
- Paste the token in your
.envfile
Step 5: Invite Bot to Your Server
- In the Discord Developer Portal, go to "OAuth2" > "URL Generator"
- Select scopes:
bot - Select bot permissions:
- Send Messages
- Add Reactions
- Read Message History
- Embed Links
- Use the generated URL to invite the bot to your server
Step 6: Run the Bot
python bot.pyHow to Play
Playing a MadLib
- Use
&playfor a random MadLib or&play [title]for a specific one - The bot will prompt you for different types of words (nouns, verbs, adjectives, etc.)
- Type your word when prompted
- Enjoy the hilarious results!
Creating Your Own MadLib
- Use
&newto start creating a template - Choose option 1️⃣ to create or 2️⃣ to view instructions
- Write your story, using
<word type>for blanks (e.g.,<noun>,<adjective>,<body part>) - Example:
"The <adjective> cat <verb (past-tense)> over the <noun>" - Confirm your template and give it a title
File Structure
madlibs_bot/
├── bot.py # Main bot application
├── default_templates.py # Pre-made MadLib templates
├── storage.py # JSON storage management
├── requirements.txt # Python dependencies
├── .env.example # Example environment variables
├── .env # Environment variables (you create this)
├── madlibs.json # Stored templates (auto-generated)
└── README.md # This file
Technical Details
- Framework: discord.py
- Python Version: 3.8+
- Command Prefix:
& - Timeout: 60 seconds for user responses
Contributing
- Fork the repository
- Create a 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
Troubleshooting
Common Issues
- Bot doesn't respond: Check if the bot has the necessary permissions in your server
- Token errors: Verify your
DISCORD_TOKENin the.envfile - Import errors: Make sure all dependencies are installed with
pip install -r requirements.txt
Need Help?
- Check the console output for error messages
- Ensure the bot has proper permissions in your Discord server
- Verify all files are in the correct directory structure
License
This project is open source and available under the MIT License.
Support
If you encounter any issues or have questions, feel free to:
- Open an issue on GitHub
- Check the troubleshooting section above
- Review the command documentation
Made with ❤️ for Discordians who love word games!