A powerful Discord bot powered by g4f that leverages free AI models for text generation and image creation. This bot provides seamless integration with Discord's slash commands for an intuitive user experience.
- Text Generation — Generate intelligent responses using advanced AI models via the
/askcommand - Image Generation — Create stunning images from text descriptions using the
/imagecommand - Help Command — Easy access to command documentation with
/help - Asynchronous Processing — Non-blocking operations for optimal performance
- Base64 Image Support — Direct image delivery without external dependencies
Before you begin, ensure you have the following installed:
- Python 3.8 or higher
- pip (Python package manager)
- A Discord bot token from the Discord Developer Portal
git clone https://github.com/Aegis-plus/ai-discord-bot.git
cd ai-discord-botpip install -r requirements.txtCreate a .env file in the root directory with the following content:
DISCORD_TOKEN=your_discord_bot_token_hereHow to get your Discord token:
- Visit the Discord Developer Portal
- Create a new application or select an existing one
- Navigate to the "Bot" section
- Click "Add Bot"
- Under the TOKEN section, click "Copy" to copy your token
- Paste it into your
.envfile
python bot.pyOnce the bot is running, you should see a confirmation message in the console:
Bot is ready. Logged in as YourBotName#0000
Generate text responses using AI models.
Example:
/ask What is the capital of France?
Response: The bot will generate an intelligent response based on your prompt.
Generate images from text descriptions.
Example:
/image A serene mountain landscape at sunset
Response: The bot will generate and send an image matching your description.
Display all available commands and their descriptions.
Response: An embedded help message with all available commands.
The bot requires the following environment variable to be set in your .env file:
| Variable | Description |
|---|---|
DISCORD_TOKEN |
Your Discord bot token for authentication |
The bot currently uses:
- PollinationsAI for text generation
- ApiAirforce for image generation
These providers are configured in the code and require no additional setup.
| Package | Purpose |
|---|---|
nextcord |
Discord bot framework |
python-dotenv |
Environment variable management |
g4f |
Free AI model access |
ai-discord-bot/
├── bot.py # Main bot file with command implementations
├── requirements.txt # Python dependencies
├── .env # Environment variables (not tracked in git)
├── .gitignore # Git ignore rules
└── README.md # This file
- Verify that the bot has the necessary permissions in your Discord server
- Ensure the
DISCORD_TOKENin your.envfile is correct - Check that the bot is online (status should show as "Online")
- Make sure you're using the correct slash command syntax (
/command_name) - Ensure the bot has been invited to your server with the
applications.commandsscope
- Check your internet connection
- Verify that g4f providers are accessible
- Consider rate limiting if making too many requests
Contributions are welcome! Feel free to submit issues or pull requests to improve the bot.
This project is licensed under the MIT License. See the LICENSE file for details.
This bot uses free AI models via g4f. The quality and availability of responses depend on the underlying providers. Use responsibly and in accordance with Discord's Terms of Service.
For issues, questions, or suggestions, please open an issue on the GitHub repository.
Last Updated: November 2025