midjourney-api: error 400 when testing command
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
}
}
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 38 (12 by maintainers)
WORKING!!! Thanks sir!! You´ve saved me hours of searching
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
I see, thanks.
It was in their status channel
Working again! The duplicated was a logic problem in my code (solved)
thank you dude
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.