GithubHelp home page GithubHelp logo

wildric-auric / midjourney-wrapper Goto Github PK

View Code? Open in Web Editor NEW
693.0 12.0 151.0 21 KB

MidJourney wrapper in Discord.

License: Creative Commons Zero v1.0 Universal

Python 100.00%
ai discord midjourney discord-bot discord-py python requests selfbot wrapper-api api

midjourney-wrapper's Introduction

WARNING

DUE TO LACK OF TIME AND MULTIPLE API'S UPDATES, THIS REPOSITORY IS NOT UP TO DATE, AND MAY BE DEPRICATED. I MAY CONSIDER COMING BACK TO THIS PROJECT LATER...

MidJourney-Wrapper

Presentation

The point of this bot is using MidJouney from an account other than the account you paid from. To do so, there should be a Discord bot, which we will call DaVinci (see Globals), and the account subscribed to MidJourney, which we will call Salai, in the same server. Any discord user in the server can use DaVinci commands to generate images, their variations, upscale them...
Warning though; you aren't allowed to use this software in the purpose of sharing your subscription with other people; this software is intended to be used only for learning purposes. If you infringe the rules, please know that you are solely responsible.

Installation

  • Clone the project.
  • Install requirements (only pycord version 2) and discord python api module if needed.
  • Fill Globals.py with your data
  • Run main.py;

Implemented commands documentation

MT stands for mandatory OPT stands for optional

Generating idea

/mj_imagine [ MT : prompt (string)]

ezgif-3-c4476f9a09

Targetting image

Reply to MidJourney Bot message by the following command to target that piece of art for the next operation:

$mj_target

Notice that slash command is not used here because of discord not allowing Interactions during reply. Hence, there is no autocomplete, your reply is simply parsed to get the command.

ezgif-3-c4476f9a09

Upscaling and variations

/mj_upscale [ MT : index (integer) ] [ OPT : reset_target (boolean) ]

index parameter takes values from 1 to 4; 1 is the index of top left image and 4 is the index of buttom right one. The optional parameter reset_target indicates if target you have set before should be reset at the end of current operation; if that's done and you want to upscale image from same message with different index you should use $mj_target command again.

ezgif-3-c4476f9a09

Generated image:

image

Notice that we cannot use /mj_upscale_to_max on this output since we used --hd parameter which makes a sigle upscale maximized.
This last command does not require a parameter and it resets target since no other operation is possible on this output other than upscaling to max. But remember that you need again to target what you need to upscale for the second time.

There is another command that uses the output of /mj_imagine:

/mj_upscale_to_max [ MT : index (integer) ] [ OPT : reset_target (boolean) ]

It behaves the same way as upscaling command.

Additional information

Even though a request error is caught by the bot (a problem with MidJourney bot, a problem with the subscripted account...) since it shows up as HTTP request error, it does not caught errors done by the user; for example if there was a typo using MidJourney parameters like -hd instead of --hd MidJourney reports it to the subscripted user but DaVinci does not complain about it, so pay attention to your inputs. Also read the official user documentation of MidJourney.

Enjoy!

midjourney-wrapper's People

Contributors

wildric-auric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

midjourney-wrapper's Issues

Midjourney token

Hey, where to get midjourney token? SALAI?
I went thru my whole account and didnt find it. I paid for the acc thanks a lot

Error code 50035, INTERACTION_APPLICATION_COMMAND_INVALID_VERSION

Hi everybody,

A few days ago I called the API fine, until today I am getting error

Code 50035, INTERACTION_APPLICATION_COMMAND_INVALID_VERSION,
"message": "This command is outdated, please try again in a few minutes".

I guess it is due to 2 param: session_id and version change.
If anyone has solved it, please guide me
Thanks

Screenshot 2023-02-23 at 21 57 37

Error 401

Hi i think its need update again , i have same issue error 401 after update ^^ thank you :)

Error 400

Hiii , i'm trying your bot but when i try to generate image , i got this error {"message": "Unknown Integration", "code": 10005}
400 , if you can help me it would be really nice .

Thank you .

Cant seem to fix this error 405

Getting this error. Cant seem to fix it, gives requests has failed in chat when trying to imagine.

Ignoring exception in on_connect Traceback (most recent call last): File "C:\Python310\lib\site-packages\discord\client.py", line 352, in _run_event await coro(*args, **kwargs) File "C:\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect await self.register_commands() File "C:\Python310\lib\site-packages\discord\bot.py", line 460, in register_commands await self.http.bulk_upsert_command_permissions( File "C:\Python310\lib\site-packages\discord\http.py", line 338, in request raise HTTPException(response, data) discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed

Still work there?

I got "Request has failed; please try later" for every command right now.
Still working there?

Request has failed; please try later

Hello, the bot always take the response: "Request has failed; please try later" since 2023.02.04.
It joined the server but on console there has no print line of "Logged in as {bot.user}".

How to get the targetHash

Hi! Thank you so much for your great work on this project!
I would like to ask where could I find the targetHash, I have tried to look for it in the response url but that string is not correct. Is there anything that I've missed? Thank you very much!

Is there a method to execute commands such as/info and/fast, and receive a reply to a private message?

I modified the code to use Python to operate Salai to execute commands, instead of using Davinci to listen and receive messages. However, I don't know how to make Salai send/info,/fast commands to Midjournal, and after manually sending the command, the returned information is only visible to individuals, and Davinci cannot listen to the returned information. Is there any good solution to this requirement?

how to get 'a pair of message '

when my bot send imagine prompt to midjourney bot and midjourney bot says 'Waiting to start' called msg1

when images are ready , midjourney bot send the result , called msg2

except 'message.content' , is there any message's attribute that can be able to match each other ?

many thanks

Another interaction way for UV and refresh

some advice which I'm using right now is creating my own button message and store the information of uv and refresh
for interaction. this can avoid the issue when two or more people modify the $value at the same time.
E9746640-596D-4A5A-BF61-CE7E1C4E0032

invalid imaginary literal

Traceback (most recent call last):
File "C:\Users\eli\Downloads\MidJourney-Wrapper-main (1)\MidJourney-Wrapper-main\main.py", line 2, in
import Globals
File "C:\Users\eli\Downloads\MidJourney-Wrapper-main (1)\MidJourney-Wrapper-main\Globals.py", line 3
DAVINCI_TOKEN = [MTA3NTgzMTgxNzIxMjUzODkzMA.GaDiF3.4JqveURuYiNUY40dOBsJUyv10l2F-NkpYG1F0]
^
SyntaxError: invalid imaginary literal

Anyone know how to fix this?

Error 405, bot does not work.

When I run the bot, I get the following error

Ignoring exception in on_connect
Traceback (most recent call last):
  File "/home/mble/.local/lib/python3.10/site-packages/discord/client.py", line 352, in _run_event
    await coro(*args, **kwargs)
  File "/home/mble/.local/lib/python3.10/site-packages/discord/bot.py", line 793, in on_connect
    await self.register_commands()
  File "/home/mble/.local/lib/python3.10/site-packages/discord/bot.py", line 460, in register_commands
    await self.http.bulk_upsert_command_permissions(
  File "/home/mble/.local/lib/python3.10/site-packages/discord/http.py", line 338, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed
Logged in as h4xx3d midjourney#1614

Bot is online, but is unable to generate anything:
image

Setup help

Hi, I really need your help for installing process I am kinda stuck at the DaVinci Bot and Your bot's implementation.

always bad request 400. SOLVED i didnt see the update in the salai.py, sorry

The wrapper was perfect, untill a few days ago, when i started getting 400 bad request. the responce.content is:
{"code": 50035, "errors": {"data": {"_errors": [{"code": "INTERACTION_APPLICATION_COMMAND_INVALID_VERSION", "message": "This command is outdated, please try again in a few minutes"}]}}, "message": "Invalid Form Body"}

I tried changing in salai.py from https://discord.com/api/v9/interactions to https://discord.com/api/v10/interactions
but it doesnt work.
i also tried reinviting the midjourney bot to my server.
i also tried looking through the discord documentations about interactions and stuff like that, and i tried changing in salai.py. still doesnt work.

please help.

Variation Remix

anybody try Variation Remix mod?
I was suck on this mod . step 1 is same as normal Variation function , step 2 , when fill some additional prompt in popup and submit , there is an 'id' in 'data' item , like this
data: {id: "1094988422625636472",

the web api called 'interaction' , i guess it maybe 'interaction.id' of midjourney bot . but how to get it ..

Can I save pictures to my PC?

What is the principle of this project? Did you forward the request to another Dicord channel? Can I access MidJourney through discord's API to retrieve images and save them locally? Thank you

unknown guild error 10004

Hi,
I have checked the other github post with this error, however I can't resolve this
{"message": "Unknown Guild", "code": 10004}

I have checked the Globals.py file and made sure that the IDs are correct and Tokens are correct.

So just to be clear
I can do /mj_imagine cyberpunk tokyo

Then it loads
Then it says
Request has failed; please try later
In terminal I see {"message": "Unknown Guild", "code": 10004}

How do I fix this?

Thank you!

discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed

C:\Users\Administrator\Desktop\MidJourney-Wrapper-main>python main.py
Ignoring exception in on_connect
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 352, in _run_event
await coro(*args, **kwargs)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 793, in on_connect
await self.register_commands()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\bot.py", line 460, in register_commands
await self.http.bulk_upsert_command_permissions(
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\http.py", line 338, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed

do you know any reason that he error 405 in program first one.
error 401 when prompt submitted
image

Unknown Integration Code 10005

Running the bot works but using slash commands returns this error. Any suggestions?

<Response [400]>
{"message": "Unknown Integration", "code": 10005}

how to set up global settings?

Hi, I am new here. I have questions about how to find kinds of IDs that needed to be filled in global.py.

DAVINCI_TOKEN = [Token of Discord bot] ##where to find this token?

SERVER_ID = [Server id here] ##where to find this ID?

SALAI_TOKEN = [Token of the Account from which you paid MidJourney ] ## solved through other post

CHANNEL_ID = [Channel in which commands are sent] ##where to find this ID?

Besides, how to invite DAVINCI Bot to my server on Discord Website

Setting parameters

Where to get the" SALAI_TOKE "? Would you like a screenshot or detailed explanation? Thank you.

Request has failed; please try later & Name Error

The bot's hello command works fine on the server but when I try the imagine command I get a request has failed, try again later error.

error

Also my tokens have periods in them (.) causing a name error

image

Those aren't my full values, I removed several characters to protect my information. Apparently the (.) is causing some problems with my tokens being read correctly. Do I need to format them in a certain way?

Get bot to respond inside discord channel it is being prompted from

@Wildric-Auric

Hi! is it possible to modify the python script so that the bot can respond inside the channel the prompt is given in?
E.g. say I have
Discord ==> Channel A, Channel B , Channel C
Bot is currently setup in Channel A
Bot is then added to Channel B from inside discord
** Currently if I prompt the bot from Channel B it submits the reply into Channel A **

Is there a way to update the python script so that the bot can reply inside channel B from where the prompt came from?

Thank you!

Receive messages rejected by mid

Sometimes, I accidentally send certain words, or repeatedly try to zoom in on the same picture. The mid robot will reply with a message that only subscribed accounts can see. Tell you what went wrong.
Is there currently a way to catch this message in python?

Exception has occured, maybe you didn't reply to MidJourney message

I did reply the message, still got this error.
Exception has occured, maybe you didn't reply to MidJourney message
I debug it found:
Globals.targetHash = str((message.reference.resolved.attachments[0].url.split("_")[-1]).split(".")[0])
message.reference.resolved.attachments is empty.

The second error is:
I modifed guild_id to my server id. it can send message and get the results in Salai , but still get error when started.
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed,

Unauthorized

i use java,but have Unauthorized error, i dont know why, please

Possible button interaction changes?

I've spent some time trying to figure out a way to either remove the buttons sent within the Midjourney responses altogether or trigger the paid user token to complete the V1-4 or U1-4 interactions. Not much luck.

I did manage to get my bot to remove the Midjourney artwork response, then insert my own using the captured attachments and message content data before removing it via both the on_message and on_message_edit events, but I can definitely see issues if high volumes of messages are sent in a short period of time.

Anyone have an idea on how to get the Midjourney response buttons to use the user token? The fact that they display and non-paid discord members can interact with them is a bit annoying.

python3 main.py Logged in as DAVINCI#0703

Hi,
it says:

$ python3 main.py
Logged in as DAVINCI#0703

but it doesnt work on the discord server, I Dont see any bot and commands doesnt work, do you have an idea why? thanks a lot

Using MidJourney's Bot command in our own bot like DaVinci

I created my own bot and added MidJourney's bot to my server's channel. I am creating my application in Java using JDA Library. When my bot sends message to the channel in which MidJourney's bot exists, it does not recognize my bot's command (such as /imagine [prompt]". How do I make it like DaVinci bot as yours which recognizes MidJourney's bot commands and executes those command like yours.
Thank You.

Upscaling doesn't work due to additional string from Midjourney

Hi Oussama,

I opened this issue as you asked for raising the current issue with Midjourney Upscaling feature.
Till now, as you told me, the following data payload was required for generating new Upscale interaction requests:
"custom_id":f"MJ::JOB::upsample::{index}"
When I tried to run this code I encounter a problem due to the fact that probably Midjourney included another piece of information that required for the payload. This string (red) is a specific identifier that represents an image that was created with /imagine command.
Notice that all 4 images that were generated by th /imagne / /mj_imagne command shared the same string
image

Request has failed; please try again later

ref: #19

I am having the same issue now after restarting the bot many times experimenting with a batch code to start it, and now have this issue. Midjourney bot is still in the channel, unlike the previous issue tracker. Wonder if i'm hitting some kind of rate limit (using MidJourney bot as usual is not having errors).

HTTP Exception 401

Hi, the bot logs in successfully, but running a /mj_image command results in a 401 exception.
Both DaVinci and Salai are running on administrator privileges.
I didn't modify the code except for the first 4 constants in global.py
Is this working for you guys?

Feature Request: Multiple Channels

Hello!
When I utilize 'DaVinci' in a different channel, the 'other bot' generates the content and only displays it in the designated channel specified in the Globals.py file. However, I'm curious if it's possible to expand the bot's functionality by enabling it to show the content in multiple permitted channels. Specifically, it would be ideal if the bot could display the generated content in the same channel where the /mj_imagine command was initiated. Would it be possible to implement this feature?

AutoUpscale function

I would like too see an option to auto uposcale generated images.

AutoUpscale = True

HTTPException: 405

I met the following error:

PS F:\midjourney\MidJourney-Wrapper> python .\main.py
Ignoring exception in on_connect
Traceback (most recent call last):
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\client.py", line 352, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\bot.py", line 793, in on_connect
    await self.register_commands()
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\bot.py", line 460, in register_commands
    await self.http.bulk_upsert_command_permissions(
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\http.py", line 338, in request
    raise HTTPException(response, data)
discord.errors.HTTPException: 405 Method Not Allowed (error code: 0): 405: Method Not Allowed
Logged in as BoilSheepSheep#7113

I tried to ignore it and write prompt in my channel, but I saw:

Ignoring exception in command <discord.commands.SlashCommand name=mj_imagine>:
Traceback (most recent call last):
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\commands\core.py", line 110, in wrapped
    ret = await coro(arg)
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\commands\core.py", line 766, in _invoke
    await self.callback(ctx, **kwargs)
  File "F:\midjourney\MidJourney-Wrapper\main.py", line 27, in mj_imagine
    print(response.txt)
AttributeError: 'Response' object has no attribute 'txt'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\bot.py", line 520, in process_application_commands
    await ctx.command.invoke(ctx)
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\commands\core.py", line 306, in invoke
    await injected(ctx)
  File "C:\Users\yifan\miniconda3\envs\midjourney\lib\site-packages\discord\commands\core.py", line 116, in wrapped
    raise ApplicationCommandInvokeError(exc) from exc
discord.commands.errors.ApplicationCommandInvokeError: Application Command raised an exception: AttributeError: 'Response' object has no attribute 'txt'

The in my channel, the problem is looked like this:
image

400 imagine payload issue? (RESOLVED)

It seems to happen 50% of the time using the /mj_imagine command. It wasn't happening before this evening, so I'm not sure whats going on.

{"code": 50035, "errors": {"data": {"_errors": [{"code": "INTERACTION_APPLICATION_COMMAND_INVALID_PERMISSIONS", "message": "You do not have permission to use this command"}]}}, "message": "Invalid Form Body"}

443 ssl exceptions

i keep receiving these exceptions, Mac OS
and i dont know how to fix it

raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discord.com:443 ssl:default [Connect call failed ('199.59.149.238', 443)]

Refresh button

I wonder how and where to check the payload information?
I want to add a function to use the 🔄 button.

Can I use it as an api in python

Hi, I want to use midjourney in my web application, can I use this wrapper to use mid journey in python, without calling anything over discord.

Request has failed; please try later

Hi,

I think I've install wrapper correctly but still I am not able to generate pictures.
It just keeps saying "Request has failed; please try later"

Here is my sample:

#every variable is a string

DAVINCI_TOKEN = "My servers bot token that I've created"

SERVER_ID = [My server id]

CHANNEL_ID = [My channel id - can there be multiple?]

SALAI_TOKEN = "my account token that I've paid"

MID_JOURNEY_ID = "936929561302675456" #midjourney bot id
#don't edit the following variable
targetID = ""
targetHash = ""

Do I need to add some info to "targetID and targetHash" part? and if yes - what do I need to add there?

Sorry for stupid questions

Couldn't run this code

Hi I install all the required library,but when I run python main.py I got following error, I created a virtualenv to run this piece of code and I am using Python 3.11.1

Traceback (most recent call last): File "C:\projectx\MidJourney-Wrapper\main.py", line 18, in <module> @bot.command(description="This command is a wrapper of MidJourneyAI") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\projectx\MidJourney-Wrapper\myenv\Lib\site-packages\discord\bot.py", line 587, in decorator result = command(**kwargs)(func) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\projectx\MidJourney-Wrapper\myenv\Lib\site-packages\discord\commands\core.py", line 1433, in decorator return cls(func, **attrs) ^^^^^^^^^^^^^^^^^^ File "C:\projectx\MidJourney-Wrapper\myenv\Lib\site-packages\discord\commands\core.py", line 555, in __init__ super().__init__(func, **kwargs) File "C:\projectx\MidJourney-Wrapper\myenv\Lib\site-packages\discord\commands\core.py", line 141, in __init__ from ..ext.commands.cooldowns import CooldownMapping, BucketType, MaxConcurrency File "C:\projectx\MidJourney-Wrapper\myenv\Lib\site-packages\discord\ext\commands\__init__.py", line 19, in <module> from .flags import * File "C:\projectx\MidJourney-Wrapper\myenv\Lib\site-packages\discord\ext\commands\flags.py", line 73, in <module> @dataclass ^^^^^^^^^ File "C:\Program Files\Python311\Lib\dataclasses.py", line 1220, in dataclass return wrap(cls) ^^^^^^^^^ File "C:\Program Files\Python311\Lib\dataclasses.py", line 1210, in wrap return _process_class(cls, init, repr, eq, order, unsafe_hash, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Python311\Lib\dataclasses.py", line 958, in _process_class cls_fields.append(_get_field(cls, name, type, kw_only)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\Python311\Lib\dataclasses.py", line 815, in _get_field raise ValueError(f'mutable default {type(f.default)} for field ' ValueError: mutable default <class 'discord.utils._MissingSentinel'> for field name is not allowed: use default_factory

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.