midjourney api by discord
- Imagine
- Scale
- Select
wait pr
-
Create console app
mkdir Midjourney.Example.Console && cd Midjourney.Example.Console dotnet new console dotnet add package MidjourneyAPI --version 1.0.0-beta.2305181719 dotnet add package Micorsoft.Extensions.Logging.Console dotnet add pacakge Micorsoft.Extensions.DependencyInjection
-
Edit
Program.cs
var services = new ServiceCollection(); services.AddLogging(builder => { builder.SetMinimumLevel(LogLevel.Debug); builder.AddConsole(); }); services.AddMidjourney(builder => { // Note: Please set your custome info. builder.Option.DiscordToken = "<your discord authorization value>"; builder.Option.ChannelId = "<your discord server id>"; builder.Option.ServerId = "<your midjourney bot channelId in discord>"; }); var provider = services.BuildServiceProvider(); var midjourney = provider.GetRequiredService<Midjourney>() ?? throw new ArgumentNullException(nameof(Midjourney)); // Imagine await midjourney.ImagineAsync("Labrador", loading: (message) => { Console.WriteLine(message.Progress); if (message.Progress == "done") { Console.WriteLine($"{message.Content} -> {message.Url}"); } return Task.CompletedTask; });
-
Run your code for
dotnet run
-
Get
DiscordToken
-
Get
ServerId
Press
F12
, Open your discordServer profile
, Find/profile
forNetworking
and viewpayload
, selectguild_id
inmutual_guilds
-
Get
ChannelId
Press
F12
, Select click your channel in discord, Find/messages
forNetworking
and viewpayload
, selectchannel_id
in data list
-
git clone
https://github.com/binwan-dev/MidjourneyAPI
-
config
SalaiToken
ServerId
ChannelId
atProgram.cs
insrc/example/MidjourneyAPI.Example
services.AddMidjourney(builder => { builder.Option.DiscordToken = "<your discord authorization value>"; builder.Option.ChannelId = "<your discord server id>"; builder.Option.ServerId = "<your midjourney bot channelId in discord>"; });
-
run
example
cd MidjourneyAPI/src/example/MidjourneyAPI.Example.Console dotnet run
https://github.com/erictik/midjourney-api
The project is to be used for educational purposes only