
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
midjourney-discord-api
Advanced tools
midjourney-discord-api
is a library designed to connect to a Discord channel
and send messages to be processed by the Midjourney bot. It utilizes the same
requests as the Discord web client, allowing seamless communication with the
bot. To configure the library, extract an authenticated request sent to the
Midjourney bot using your web development tools.
feature | Status | feature | Status |
---|---|---|---|
/blend | ✅ | Reroll | ✅ |
/describe | ✅ | /relax | ✅ |
/fast | ✅ | /settings | ✅ |
/imagine | ✅ | Variations | ✅ |
Upscale | ✅ | concurent calls | ✅ |
/private | ❌ N/A | /public | ❌ N/A |
/show | ❌ N/A | /stealth | ❌ N/A |
npm install midjourney-discord-api
deno add @u4/midjourney
import Midjourney from "@u4/midjourney";
npx jsr add @u4/midjourney
import Midjourney from "@u4/midjourney";
import Midjourney from "midjourney-discord-api";
// or
// import Midjourney from "@u4/midjourney";
const cli = new Midjourney("interaction.txt");
const msgs = await cli.getMessages();
console.log(msgs.length + " messages visibles"); // by default get 50 messages
// deno add @u4/midjourney
import Midjourney from "@u4/midjourney";
// using x
// import Midjourney from "midjourney-discord-api";
F12
on windows Command ⌘
+ Option ⌥
+ I
on mac)https://discord.com/api/v9/interactions
request or https://discord.com/api/v9/science
.Copy
Copy as fetch
Midjourney
constructor. (for my Test I name this file interaction.txt
)the Midjourney client can be initilized in 4 different ways:
in this case the provided file should contains a valid NodeJS fetch command as described in the previous section.
filename
can also be replace by it's content.
in this case the provided file should contains somthink like:
SALAI_TOKEN = your 72 char long authorization token
SERVER_ID = the serverId
CHANNEL_ID = the channelId
SERVER_ID
and CHANNEL_ID
can be omit, if you provide those data using Midjourney.setDiscordChannelUrl("https://discord.com/channels/1234567890/1234567890")
in this case SALAI_TOKEN
should contains you 72 char long authorization token.
SERVER_ID
and CHANNEL_ID
should contains the serverId and channelId
SERVER_ID
and CHANNEL_ID
can be omit, if you provide those data using Midjourney.setDiscordChannelUrl("https://discord.com/channels/1234567890/1234567890")
in this case a 72 char long SALAI_TOKEN
token should be pass to the Midjourney
constructor like: new Midjourney(SALAI_TOKEN)
then you will have to provide serverId and channelId using Midjourney.setDiscordChannelUrl("https://discord.com/channels/1234567890/1234567890")
Here are some examples of how to use the Midjourney
class:
import Midjourney from "midjourney-discord-api";
// or
// import Midjourney from "@u4/midjourney";
const client = new Midjourney("interaction.txt");
await client.connectWs(); // Used Websocket to boost detection. (experiental)
const prompts: string[] = await client.describeUrl(
"https://cdn.midjourney.com/95e2c8fd-255c-4982-9065-83051143570c/0_0_640_N.webp",
// add optional progress function (percent) => void
);
console.log("reversed prompt: ", prompts);
import Midjourney from "midjourney-discord-api";
// or
// import Midjourney from "@u4/midjourney";
const client = new Midjourney("interaction.txt");
await client.connectWs(); // Used Websocket to boost detection. (experiental)
const msg = await client.imagine(
"A photo of an astronaut riding a horse",
// add optional progress function (percent) => void
);
console.log("you find your result here: ", msg.attachments[0].url);
// Upscale the first none upscaled images in chat, searching from the newest to the oldest images
import Midjourney from "midjourney-discord-api";
// or
// import Midjourney from "@u4/midjourney";
// Variant the last image available in chat
const client = new Midjourney("interaction.txt");
await client.connectWs(); // Used Websocket to boost detection. (experiental)
const msgs = await client.getMessages();
main:
for (const msg of msgs) {
if (!msg.canVariant()) {
continue;
}
for (let i = 1; i <= 4; i++) {
const v = msg.canVariant(i)
if (v) {
console.log(`Variant image ${v.custom_id} from ${msg.id}: ${msg.prompt?.prompt}`);
const result = await msg.variant(i);
await result.download(0, "images");
break main;
}
}
}
// Variant the last image available in chat
const client = new Midjourney("interaction.txt");
await client.connectWs(); // Used Websocket to boost detection. (experiental)
const msgs = await client.getMessages();
main:
for (const msg of msgs) {
if (!msg.canVariant()) {
continue;
}
for (let i = 1; i <= 4; i++) {
const v = msg.canVariant(i)
if (v) {
console.log(`Variant image ${v.custom_id} from ${msg.id}: ${msg.prompt?.prompt}`);
const result = await msg.variant(i);
await result.download(0, "images");
break main;
}
}
}
import Midjourney from "midjourney-discord-api";
// or
// import Midjourney from "@u4/midjourney";
const client = new Midjourney("interaction.txt");
await client.connectWs(); // Used Websocket to boost detection. (experiental)
const msg = await client.imagine(
"A photo of an astronaut riding a horse",
// add optional progress function (percent) => void
);
if (msg.canReroll()) {
const result = msg.reroll();
console.log(`upscale V2 Ready from`, result.attachments[0].url);
}
check all the samples here
name | function |
---|---|
ImagineSet.ts | Call concurent /imagine function at the same time |
blendImages.ts | blend 2 random images |
describeRegen.ts | descript an image then imagine the returned prompts |
listLastMsgs.ts | list last message |
parseOne.ts | debug one message |
progressLogger.ts | a progress logger provider |
sampleUrls.ts | samples Image url used in test script |
saveAll.ts | download all image from a channel |
upscaleLast.ts | upscall the last non upscalled image |
upscaleLasthoursAgo.ts | upscall an image at a specific time |
variantLast.ts | generate variante for a the last generated image |
We welcome contributions to the midjourney-discord-api project. Please feel free to submit issues, feature requests, and pull requests to improve the project.
This project is licensed under the MIT License.
FAQs
Midjourney client using Discord.
The npm package midjourney-discord-api receives a total of 232 weekly downloads. As such, midjourney-discord-api popularity was classified as not popular.
We found that midjourney-discord-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.