forked from erictik/midjourney-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimagine-niji.ts
39 lines (39 loc) · 885 Bytes
/
imagine-niji.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import "dotenv/config";
import { Midjourney, NijiBot } from "../src";
/**
*
* a simple example of using the imagine api via DM Niji Bot
* ```
* npx tsx example/imagine-niji.ts
* ```
*/
async function main() {
const client = new Midjourney({
SalaiToken: <string>process.env.SALAI_TOKEN,
BotId: NijiBot, // NijiBot
ChannelId: "1125452970276954204",
Debug: true,
Ws: true,
});
await client.Connect();
const info = await client.Info();
console.log(info);
const msg = await client.Imagine(
"A little white dog",
(uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
}
);
console.log( msg );
client.Close();
}
main()
.then(() => {
// console.log("finished");
// process.exit(0);
})
.catch((err) => {
console.log("finished");
console.error(err);
process.exit(1);
});