DEV Community

Aditya
Aditya

Posted on

Discord Image Generation Bot with Daytona

This project demonstrates how to build a Discord bot that generates images from text prompts using the Prodia API, while utilizing Daytona for an optimized and scalable development environment. With Daytona's devcontainers, the bot ensures a standardized, fast, and efficient setup process.

Table of Contents

  1. πŸš€ Getting Started
  2. ✨ Features
  3. πŸ’¬ How to Use
  4. πŸ“œ License
  5. πŸ“š Learn More

πŸš€ Getting Started

1. Install Daytona

First, make sure you have Daytona installed. You can follow the installation guide from the Daytona documentation.
Start the server

   daytona serve;
Enter fullscreen mode Exit fullscreen mode

2. Clone the Repository

Clone this repository to your local machine:

   git clone https://github.com/TheCoderAdi/discord-bot.git
   cd discord-bot
Enter fullscreen mode Exit fullscreen mode

3. Create a Daytona Workspace

Create a development workspace using Daytona:

   daytona create https://github.com/TheCoderAdi/discord-bot
Enter fullscreen mode Exit fullscreen mode

4. Install Dependencies

Once you have set up your workspace, ensure all dependencies are installed by running:

   pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

5. Configure the Bot

Create a .env file in the root directory of the project and add your Discord bot token and Prodia API key as follows:

   DISCORD_TOKEN=your_discord_bot_token
   PRODIA_API_KEY=your_prodia_api_key
Enter fullscreen mode Exit fullscreen mode

6. Run the Bot

After configuring the bot, you can start it by running:

   python bot.py
Enter fullscreen mode Exit fullscreen mode

This will start the bot, which will listen to messages on your Discord server and respond with generated images based on text prompts.

✨ Features

  • Integration with Daytona:

    Daytona ensures a consistent, reproducible development environment with devcontainers for easy setup and scaling.

  • Modular Python Bot Framework:

    The bot is designed to be modular and extendable. You can easily add new features or commands.

  • Discord API Integration:

    Uses the Discord API to handle real-time message interaction in the server.

  • Image Generation with Prodia API:

    Generates images based on text prompts, utilizing the Prodia API to create AI-driven images.

πŸ’¬ How to Use

Once the bot is up and running, you can interact with it directly in any Discord channel where the bot is present.

1. Text Prompt Command

To generate an image, use the command !generate followed by the text prompt. For example:

   !generate A sunset over a mountain range
Enter fullscreen mode Exit fullscreen mode

The bot will process your request and return the generated image. The output will be displayed in the channel like so:

Output Image:

Example

The bot will send back the image in the Discord channel once the image generation is completed.

πŸ“œ License

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

πŸ“š Learn More

Top comments (0)