Giter Site home page Giter Site logo

benoiteveillard / midjourney-discord-api-php Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ferranfg/midjourney-discord-api-php

0.0 0.0 0.0 11.37 MB

Generate images using Midjourney Bot through the Discord API.

License: MIT License

PHP 100.00%

midjourney-discord-api-php's Introduction

Midjourney PHP Library for Discord API Image Generation

This PHP library provides a simple interface for generating images using the Midjourney Bot through the Discord API.

Midjourney PHP Library for Discord API

Installation

You can install this library using Composer. Run the following command in your project directory:

composer require ferranfg/midjourney-php

Usage

Basic usage

To generate an image using the Midjourney Bot, you first need to create an instance of the Midjourney class:

use Ferranfg\MidjourneyPhp\Midjourney;

$midjourney = new Midjourney($discord_channel_id, $discord_user_token);

$message = $midjourney->generate('An astronaut riding a horse');

return $message->upscaled_photo_url;

Constructor

  • $discord_channel_id - Replaces this value with the Channel ID where the Midjourney Bot is installed. You can get the Channel ID right-clicking on the channel and Copy Channel ID.

    Remember that you can invite the Midjourney Bot to your own server to organize your work https://docs.midjourney.com/docs/invite-the-bot

  • $discord_user_token - Automatic user accounts (self-bots) are not allowed by Discord and can result in an account termination if found, so use it at your own risk.

    To get your user token, visit https://discord.com/channels/@me and open the Network tab inside the Developers Tools. Find between your XHR requests the Authorization header.

    Discord User Token

Methods

$midjourney->imagine($prompt)

This method generates an image using a prompt and returns an object that represents the message containing the generated image. The $prompt parameter is a string that will be used to generate the image.

$imagine_object = $midjourney->imagine('An astronaut riding a horse');

$midjourney->getImagine($prompt)

This method returns a previously generated object that represents the message containing the image generated by the given prompt. The $prompt parameter is the string used to generate the image.

$imagine_object = $midjourney->getImagine('An astronaut riding a horse');

$midjourney->upscale($imagine_object, $upscale_index)

This method upscales an image contained in the given object and returns the URL of the upscaled image. The $imagine_object parameter is the object returned from the imagine / getImagine methods. The $upscale_index parameter is an integer between 0 and 3 that represents the option provided by the MJ bot we want to upscale.

$upscaled_image_url = $midjourney->upscale($imagine_object, 2);

$midjourney->getUpscale($imagine_object, $upscale_index)

This method returns the URL of a previously upscaled image generated by the given message and with the given option of upscaling. The $imagine_object parameter is the object returned from the imagine / getImagine methods. The $upscale_index parameter is an integer between 0 and 3 that represents the option provided to the MJ bot we upscaled.

$upscaled_image_url = $midjourney->getUpscale($imagine_object, 2);

midjourney-discord-api-php's People

Contributors

ferranfg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.