Skip to content

Aegis-plus/ai-discord-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AI Discord Bot

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.

Features

  • Text Generation — Generate intelligent responses using advanced AI models via the /ask command
  • Image Generation — Create stunning images from text descriptions using the /image command
  • 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

Prerequisites

Before you begin, ensure you have the following installed:

Installation

1. Clone the Repository

git clone https://github.com/Aegis-plus/ai-discord-bot.git
cd ai-discord-bot

2. Install Dependencies

pip install -r requirements.txt

3. Configure Environment Variables

Create a .env file in the root directory with the following content:

DISCORD_TOKEN=your_discord_bot_token_here

How to get your Discord token:

  1. Visit the Discord Developer Portal
  2. Create a new application or select an existing one
  3. Navigate to the "Bot" section
  4. Click "Add Bot"
  5. Under the TOKEN section, click "Copy" to copy your token
  6. Paste it into your .env file

Usage

Starting the Bot

python bot.py

Once the bot is running, you should see a confirmation message in the console:

Bot is ready. Logged in as YourBotName#0000

Available Commands

/ask <prompt>

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.


/image <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.


/help

Display all available commands and their descriptions.

Response: An embedded help message with all available commands.

Configuration

Environment Variables

The bot requires the following environment variable to be set in your .env file:

Variable Description
DISCORD_TOKEN Your Discord bot token for authentication

AI Providers

The bot currently uses:

  • PollinationsAI for text generation
  • ApiAirforce for image generation

These providers are configured in the code and require no additional setup.

Dependencies

Package Purpose
nextcord Discord bot framework
python-dotenv Environment variable management
g4f Free AI model access

Project Structure

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

Troubleshooting

Bot doesn't respond to commands

  • Verify that the bot has the necessary permissions in your Discord server
  • Ensure the DISCORD_TOKEN in your .env file is correct
  • Check that the bot is online (status should show as "Online")

"Command not found" error

  • Make sure you're using the correct slash command syntax (/command_name)
  • Ensure the bot has been invited to your server with the applications.commands scope

API errors

  • Check your internet connection
  • Verify that g4f providers are accessible
  • Consider rate limiting if making too many requests

Contributing

Contributions are welcome! Feel free to submit issues or pull requests to improve the bot.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Disclaimer

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.

Support

For issues, questions, or suggestions, please open an issue on the GitHub repository.


Last Updated: November 2025

About

A Discord bot powered by g4f that generates intelligent text responses and creates images using free AI models. Features slash commands for easy interaction with advanced AI capabilities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages