Feel free to tweak the script to use the built-in functions however you want. It's currently generating prompts using all so you'll get absolutely wild results like this:

⚠️ Note: You need to have Discord focused for this script to generate and paste a prompt

Open imagine-prompt in Script Kit

// Name: Midjourney Prompt
// Description: Generate a Random Midjourney Prompt
// Author: John Lindquist
// Twitter: @johnlindquist
import "@johnlindquist/kit"
let count = parseInt(
await arg({
placeholder: "How many prompts to generate and paste?",
onInput: input => {
submit(input) //auto submit the number on press
},
}),
10
)
let frontmost = await npm("frontmost-app")
let exitIfNotDiscord = async () => {
let { localizedName: name } = await frontmost()
if (name !== "Discord") {
exit()
}
}
await exitIfNotDiscord()
let n = (x = 0) =>
`::${Number(_.random(0.2, 2.2) + x).toPrecision(1)}`
let iw = (x = 0) =>
`${Number(_.random(0.2, 2.2) + x).toPrecision(1)}`
let parentDir = await env(
"MIDJOURNEY_PARENT_DIR",
async () => {
return await path({
hint: `Select a parent dir to clone the repo: https://github.com/johnlindquist/midjourney`,
})
}
)
let mjDir = path.resolve(parentDir, "midjourney")
let mjExists = await isDir(mjDir)
if (!mjExists) {
cd(parentDir)
await exec(
`git clone https://github.com/johnlindquist/midjourney`
)
cd(mjDir)
} else {
cd(mjDir)
await exec(`git pull`)
}
// await wiki() will pull a random wikipedia title
let wiki = await npm("random-word-wikipedia")
// Generate functions based on .md files in the repo
let files = await readdir(mjDir)
files = files.filter(file => file.endsWith(".md"))
for await (let file of files) {
let filePath = path.resolve(mjDir, file)
let list = await readFile(filePath, "utf-8")
let { name } = path.parse(filePath)
global[name] = () => _.sample(list.trim().split("\n"))
}
hide()
let go = async () => {
await exitIfNotDiscord()
// Customize however you want. More old "maybe working" examples here: https://github.com/johnlindquist/midjourney/blob/main/prompts.md
let fnsPrompt = `/imagine prompt: ${image()} ${myimage()} Studio photoshoot of ${celeb()} ${animal()} ${hero()}::4 ${await wiki()}${n()} in a ${color()} ${climate()}${n()} in the style of ${game()}${n()} taken by ${photographer()}${n()} by ${artist()}${n()} stylized like ${style()} and ${rank()}${n()} --stylize ${_.random(
1000,
3000
)} --uplight --aspect 16:9 --iw ${iw()}`
let prompt = _.sample([fnsPrompt])
await exitIfNotDiscord()
await setSelectedText(prompt)
log(prompt)
await wait(1000)
await exitIfNotDiscord() //I try to be extra careful when scripting the `Enter` key
await keyboard.pressKey(Key.Enter)
await keyboard.releaseKey(Key.Enter)
await wait(250) // Discord needs a sec after paste+enter to recorgnize it as a command
await exitIfNotDiscord()
await keyboard.pressKey(Key.Enter)
await keyboard.releaseKey(Key.Enter)
}
let i = 0
while (i < count) {
i++
await go()
await wait(1000)
}