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

error 400 when testing command

Open NotReks opened this issue 1 year ago • 38 comments

here's the code

const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
const axios = require('axios')
const { Midjourney } = require('midjourney');

const midjourneyClient = new Midjourney({
    ServerId: '1118903793686425631', 
    ChannelId: '1118903794374283296', 
    SalaiToken: '/// cant send that', 
    Debug: true,
    Ws: true,
});

client.once('ready', () => {
    console.log('bot is rdy')
})

client.on('messageCreate', async message => {
    if (message.content.startsWith('!imagine')) {
      console.log('Command received!'); // Debug log
      console.log(`Received message: ${message.content}`);
      const prompt = message.content.slice('!imagine '.length);
  
      try {
        console.log('Sending bot is thinking... message'); // Debug log
        const botMessage = await message.reply('Bot is cooking...');
  
        console.log('Making API request'); // Debug log
        
        const Imagine = await midjourneyClient.Imagine(prompt, (uri, progress) => {
          console.log("Imagine URI:", uri, "Progress:", progress);
        });
  
        console.log({ Imagine });
  
        console.log('Editing message with image'); // Debug log
        await botMessage.edit(`Here's your image for the prompt "${prompt}"`);
        await message.channel.send(Imagine.content); 
  
      } catch (error) {
        console.error(`Error encountered: ${error.message}`); // Debug log
      }
    }
  });



client.login('/// cant send that')```

here's the error:

Imagine [3195733217] anime girl nonce 1118907296554942464 2023-06-15T14:18:07.791Z
api.DiscordBaseUrl https://discord.com/
api.fetchUrl https://discord.com/api/v9/interactions
Error encountered: ImagineApi failed with status 400
api.error.config {
  payload: {
    type: 2,
    application_id: '936929561302675456',
    guild_id: '1118903793686425631',
    channel_id: '1118903794374283296',
    session_id: '8bb7f5b79c7a49f7d0824ab4b8773a81',
    data: {
      version: '1077969938624553050',
      id: '938956540159881230',
      name: 'imagine',
      type: 1,
      options: [Array],
      application_command: [Object],
      attachments: []
    },
    nonce: '1118907296554942464'
  },
  config: {
    ChannelId: '1118903794374283296',
    SalaiToken: '/// cant send that',
    SessionId: '8bb7f5b79c7a49f7d0824ab4b8773a81',
    Debug: true,
    Limit: 50,
    MaxWait: 200,
    DiscordBaseUrl: 'https://discord.com/',
    WsBaseUrl: 'wss://[gateway.discord.gg?v=9&encoding=json&compress=gzip-stream](http://gateway.discord.gg/?v=9&encoding=json&compress=gzip-stream)',
    ServerId: '1118903793686425631',
    Ws: true
  }
}

NotReks avatar Jun 15 '23 14:06 NotReks

check your SalaiToken u can join my discord server https://discord.com/invite/GavuGHQbV4 export SERVER_ID="1082500871478329374" export CHANNEL_ID="1094892992281718894"

zcpua avatar Jun 15 '23 14:06 zcpua

https://github.com/erictik/midjourney-api/blob/main/example/imagine-ws.ts run test

zcpua avatar Jun 15 '23 14:06 zcpua

Ok once I'm back home I'll join your discord, however I got my Salai token from the same location that it says in the documentation, however library had a region tag on it, but otherwise it was identical to the method seen in the doc

NotReks avatar Jun 15 '23 14:06 NotReks

Does midjourney need to be in? If so what's the point, I'll just use midjourney

NotReks avatar Jun 15 '23 14:06 NotReks

https://github.com/erictik/midjourney-ui u can share to non-subscribers or create webui

zcpua avatar Jun 15 '23 15:06 zcpua

It works now that midjourney is in, but all it does is send the command to that bot, I don't want midjourney to be present

NotReks avatar Jun 15 '23 15:06 NotReks

It works now that midjourney is in, but all it does is send the command to that bot, I don't want midjourney to be present

What are you trying to do? The point of this package is to programmatically talk to Discord and the Midjourney Bot so you can pass prompts and download the images with just code.

jakowenko avatar Jun 15 '23 16:06 jakowenko

dont worry about it i figured it out, image thanks for your help

NotReks avatar Jun 15 '23 16:06 NotReks

it randomly broke, it was just working like 5 minutes ago ..? can someone add me on discord @reksarts so i can discuss this further and in better detail

NotReks avatar Jun 15 '23 18:06 NotReks

I'm getting the error now too. Wonder if it's related to this message Midjourney posted in their Discord.

2023-06-15 at 14 17 55

jakowenko avatar Jun 15 '23 18:06 jakowenko

ok yeah i got that too

NotReks avatar Jun 15 '23 18:06 NotReks

You still getting the error?

NotReks avatar Jun 15 '23 18:06 NotReks

Yes, a new version will need to be published with the updated prompt version ids. I made a ticket here to track it: https://github.com/erictik/midjourney-api/issues/124

jakowenko avatar Jun 15 '23 18:06 jakowenko

I´m getting the error also

crazyramirez avatar Jun 15 '23 18:06 crazyramirez

Is there no way to temporarily Atleast fix just the imagine?

NotReks avatar Jun 15 '23 18:06 NotReks

Error Finished Error: ImagineApi failed with status 400 at Midjourney.Imagine (C:*******\src\midjourney.js:46:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

crazyramirez avatar Jun 15 '23 19:06 crazyramirez

Is there no way to temporarily Atleast fix just the imagine?

You can fix it locally and build the package. There's only 10 lines that need to be updated for everything. But to build the remote package the owner needs to merge in the change.

jakowenko avatar Jun 15 '23 19:06 jakowenko

Yeah same, since the id shit updated I was hoping if there's a way to just go into the node_modules and adjust what would be required to get the imagine working Atleast

NotReks avatar Jun 15 '23 19:06 NotReks

Oh ok it's that much work? I'm good then lmfao I'll wait

NotReks avatar Jun 15 '23 19:06 NotReks

Yeah same, since the id shit updated I was hoping if there's a way to just go into the node_modules and adjust what would be required to get the imagine working Atleast

If you want to try this you can. I think the /info one will need to be updated as well before the /imagine call happens.

/info: search for 987795925764280356 and update to 972289487818334209 /imagine: search for 1077969938624553050 and update to 1118961510123847772

jakowenko avatar Jun 15 '23 19:06 jakowenko

Yeah same, since the id shit updated I was hoping if there's a way to just go into the node_modules and adjust what would be required to get the imagine working Atleast

If you want to try this you can. I think the /info one will need to be updated as well before the /imagine call happens.

/info: search for 987795925764280356 and update to 972289487818334209 /imagine: search for 1077969938624553050 and update to 1118961510123847772

WORKING!!!! Thanks sir!! You´ve saved me hours of searching

crazyramirez avatar Jun 15 '23 19:06 crazyramirez

thank you dude

NotReks avatar Jun 15 '23 19:06 NotReks

does anything else need changed? I want to add functionality for variations and upscaling but I'm not sure if this new update broke them too

NotReks avatar Jun 15 '23 19:06 NotReks

does anything else need changed? I want to add functionality for variations and upscaling but I'm not sure if this new update broke them too

Yes, those have different IDs. Probably best just to wait until the new version is patched. I'm guessing it'll be available later today.

jakowenko avatar Jun 15 '23 19:06 jakowenko

now for some strange reason it is duplicating the request to Midjourney

crazyramirez avatar Jun 15 '23 19:06 crazyramirez

now for some strange reason it is duplicating the request to Midjourney

Working fine for me till now can you please elaborate the issue you are facing

iamkunal9 avatar Jun 15 '23 19:06 iamkunal9

does anyone know what needs to be inputted for the prompt so that it replicates the result of nijijourney? theres some discrepancies when just using --niji 5

NotReks avatar Jun 15 '23 19:06 NotReks

Working again! The duplicated was a logic problem in my code (solved)

crazyramirez avatar Jun 15 '23 21:06 crazyramirez

Sometimes midjourney asks for an appeal, and when I appeal it my bot no longer sends progress updates only the finished one, can someone help me sort it?

NotReks avatar Jun 15 '23 21:06 NotReks