Last updated:
0 purchases
midjourney client
Midjourney Client (Unofficial) #
This is an unofficial client for Midjourney that interfaces with the authentic Midjourney Bot via a Discord account token. As of now, it's stability has not been thoroughly tested. Consequently, it is advised against utilizing this client in production environments.
Table of Contents #
Midjourney Client (Unofficial)
Table of Contents
Install
Usage
Set up
How to get server id & channel id
How to get token
Examples
Imagine
Variation
Upscale
Install #
For a flutter project, consider running this command:
flutter pub add midjourney_client
copied to clipboard
For a dart project, consider running this command:
dart pub add midjourney_client
copied to clipboard
This installs the midjourney_client library and its dependencies.
Usage #
import 'dart:async';
import 'package:midjourney_client/midjourney_client.dart' as midjourney_client;
Future<void> main(List<Object> arguments) async {
final client = midjourney_client.Midjourney();
await client.initialize(
channelId: Env.channelId,
serverId: Env.serverId,
token: Env.token,
);
final imagine = client.imagine('Elephant on a tree')..listen(print);
final result = await imagine.last;
final upscaled = client.upscale(result, 1)..listen(print);
final uResult = await upscaled.last;
print(uResult);
}
copied to clipboard
Set up #
Pre-requisites:
Discord account
Discord server
How to get server id & channel id #
Open Discord app
Open your server
Right click on the message inside the channel you want to use
Copy link to message, this should look like https://discord.com/channels/${SERVER_ID}/${CHANNEL_ID}/${MESSAGE_ID}
Extract SERVER_ID and CHANNEL_ID from the link
How to get token #
This one is a bit tricky, but here's how you can get it:
Login to discord web app
Open developer tools, head for Network tab
Send a message to the channel you want to use or reload the page
Click on a random request and go to request headers
Find Authorization header and extract the value, it is your token
Examples #
This examples will instantiate a websocket connection to Discord Server and act as a Discord client sending messages to the channel specified by the CHANNEL_ID environment variable. The SERVER_ID environment variable is used to identify the server to which the channel belongs. The TOKEN environment variable is used to authenticate the client.
Imagine #
This example will trigger /imagine command on the Midjourney Bot and print the result.
dart run --define=SERVER_ID="" --define=CHANNEL_ID="" --define=TOKEN="" example/imagine.dart
copied to clipboard
import 'dart:async';
import 'dart:io';
import 'package:midjourney_client/midjourney_client.dart' as midjourney_client;
import 'env.dart';
Future<void> main(List<Object> arguments) async {
final client = midjourney_client.Midjourney();
await client.initialize(
channelId: Env.channelId,
serverId: Env.serverId,
token: Env.token,
);
final imagine = client.imagine('Cat in a hat')..listen(print);
final result = await imagine.last;
print('Result: $result');
exit(0);
}
copied to clipboard
Variation #
This example will trigger /imagine command on the Midjourney Bot, wait and trigger first variation.
dart run --define=SERVER_ID="" --define=CHANNEL_ID="" --define=TOKEN="" example/variations.dart
copied to clipboard
import 'dart:async';
import 'dart:io';
import 'package:midjourney_client/midjourney_client.dart' as midjourney_client;
import 'env.dart';
Future<void> main(List<Object> arguments) async {
final client = midjourney_client.Midjourney();
await client.initialize(
channelId: Env.channelId,
serverId: Env.serverId,
token: Env.token,
);
final imagine = client.imagine('Cat with sword')..listen(print);
final result = await imagine.last;
final variation = client.variation(result, 1)..listen(print);
final vResult = await variation.last;
print(vResult);
exit(0);
}
copied to clipboard
Upscale #
This example will trigger /imagine command on the Midjourney Bot, wait and trigger first upscale.
dart run --define=SERVER_ID="" --define=CHANNEL_ID="" --define=TOKEN="" example/upscale.dart
copied to clipboard
import 'dart:async';
import 'dart:io';
import 'package:midjourney_client/midjourney_client.dart' as midjourney_client;
import 'env.dart';
Future<void> main(List<Object> arguments) async {
final client = midjourney_client.Midjourney();
await client.initialize(
channelId: Env.channelId,
serverId: Env.serverId,
token: Env.token,
);
final imagine = client.imagine('Cat with a sword')..listen(print);
final result = await imagine.last;
final upscaled = client.upscale(result, 1)..listen(print);
final uResult = await upscaled.last;
print('Result: $uResult');
exit(0);
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.