midjourney-api icon indicating copy to clipboard operation
midjourney-api copied to clipboard

Add option to send prompts directly to Midjourney Bot via DM

Open treefort opened this issue 1 year ago • 13 comments

For accounts with the pro plan, prompts are done via Midjourney Bot DMs. Are DMs sent via the same mechanism as regular channels? How about the WS communication?

If not, it would be nice to have an option to send commands directly to the Midjourney Bot. If you can provide some guidance, I don't mind putting a PR together.

treefort avatar May 30 '23 14:05 treefort

https://github.com/erictik/midjourney-api/blob/main/src/interfaces/config.ts#L7 https://github.com/erictik/midjourney-api/blob/main/src/midjourney.ts#L101 try ServerId undefined or create a server and add Midjourney Bot to it

zcpua avatar May 31 '23 02:05 zcpua

Thanks for the suggestions-- I tried both approaches and I get "Error: ImagineApi failed with status 400."

treefort avatar May 31 '23 03:05 treefort

Did you resolve this? Also on the pro plan and I want to be able to trigger imagine commands via the api and then fetch it at a later point. Either awaiting the image being created or if it can be polled by a generating id(something of the sort).

ejkkan avatar Jun 04 '23 19:06 ejkkan

awaiting the image being created or if it can be polled by a generating id

The library actually does this already with the websockets (Ws) option set to true. I added a callback here that passed the status messages that come over the websocket to a callback function that updated an entry in my db for that particular prompt.

I couldn't get the Midjourney Bot DM thing sorted, so I just ended up adding the bot to my own discord and you can use the commands in any channel.

treefort avatar Jun 05 '23 03:06 treefort

Cool! So how'd do you get the setup working for you pro plan?

If I try to set Salai, Channel and Server Id's for my private Midjouney bot I'm getting: Error: ImagineApi failed with status 400

And If trying what zcpua suggest above and leave out he server id I get: Error: ServerId, ChannelId and SalaiToken are required

I'm not out to use it as a chat bot, but as a hosted api to send a prompt and store the image in my db.

ejkkan avatar Jun 05 '23 06:06 ejkkan

https://github.com/erictik/midjourney-api/blob/main/example/imagine-dm.ts

zcpua avatar Jun 05 '23 07:06 zcpua

@zcpua Thanks, I've re-cloned and tried the imagine-dm.ts variant. I've just checked that my SALAI_TOKEN is up to date and I still get ImagineApi failed with status 400

imagine-ws.ts now works without appending server-, channel-ids. But it also throws 400s

ejkkan avatar Jun 05 '23 08:06 ejkkan

https://discord.com/invite/GavuGHQbV4

zcpua avatar Jun 05 '23 08:06 zcpua

@zcpua in, who do i reach out to? 😅

ejkkan avatar Jun 05 '23 08:06 ejkkan

export SERVER_ID="1082500871478329374"
export CHANNEL_ID="1094892992281718894"
export SALAI_TOKEN="your-salai-token"

try again

zcpua avatar Jun 05 '23 08:06 zcpua

Still seeing the 400s with this setup.

Though I'm not exporting the config, I'm setting the env like this:

SALAI_TOKEN="*my salai token*"(authorization header from the requests)
SERVER_ID="108250087147832934"
CHANNEL_ID="109489299228171884"

Trying to log the reponses but they're not giving any messages on what seems to be wrong.

ejkkan avatar Jun 05 '23 08:06 ejkkan

@ejkkan try using server/channel IDs from the official discord just to rule out a bad config?

treefort avatar Jun 09 '23 01:06 treefort

It works if I use the setup from your discord channel. But I can't get it working when trying to use my own direct messages bot.

ejkkan avatar Jun 22 '23 17:06 ejkkan