erictik / midjourney-api

MidJourney client. Unofficial Node.js client
Apache License 2.0
1.69k stars 283 forks source link

Error while executing client.init() #192

Closed ChammounC closed 1 year ago

ChammounC commented 1 year ago

The code that reproduces this issue:

const { Midjourney } = require("midjourney");

const imagine = async (req, res) => {
    const client = new Midjourney({
      ServerId: process.env.SERVER_ID,
      ChannelId: process.env.CHANNEL_ID,
      SalaiToken: process.env.SALAI_TOKEN,
      Debug: true,
      Ws: true,
    });

    await client.init();

    const msg = await client.Imagine("A little pink elephant", (uri) => {
      console.log("loading", uri);
    });

    return res.json({msg:msg});

};

module.exports = imagine;

Error Log:

D:\react\backendTest\node_modules\midjourney\libs\command.js:82
        throw new Error(`Failed to get application_commands for command ${name}`);
              ^

Error: Failed to get application_commands for command settings
    at MidjourneyApi.getCommand (D:\react\backendTest\node_modules\midjourney\libs\command.js:82:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Midjourney.Connect (D:\react\backendTest\node_modules\midjourney\libs\midjourney.js:32:13)
    at async Midjourney.init (D:\react\backendTest\node_modules\midjourney\libs\midjourney.js:44:9)
    at async imagine (D:\react\backendTest\controllers\imagine.js:13:5)
ChammounC commented 1 year ago

Found the problem. For someone facing the same issue, check your SALAI_TOKEN or use a new one.