midjourney-api
midjourney-api copied to clipboard
Add option to send prompts directly to Midjourney Bot via DM
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.
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
Thanks for the suggestions-- I tried both approaches and I get "Error: ImagineApi failed with status 400."
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).
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.
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.
https://github.com/erictik/midjourney-api/blob/main/example/imagine-dm.ts
@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
https://discord.com/invite/GavuGHQbV4
@zcpua in, who do i reach out to? 😅
export SERVER_ID="1082500871478329374"
export CHANNEL_ID="1094892992281718894"
export SALAI_TOKEN="your-salai-token"
try again
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 try using server/channel IDs from the official discord just to rule out a bad config?
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.