背景
目前midjourney没有对外开放api,想体验他们的服务只能在discord中进入他们的频道进行体验或者把他们的机器人拉入自己创建的服务器中Midjourney Quick Start Guide(目前免费的已经无法体验了,需要使用就订阅?,后续出一个本地部署sd的)
接入midjourney需要做的事
1自己的discord服务器
2自己的机器人
3能够使用postman或者web服务触发discord服务器中的midjourney指令进行生图
4能够获取到discord服务器中的midjourney生图后的结果
完成上述的四件事后,你自己的服务中就会有midjourney生成的产物,至于给谁,可以自己决定。建议使用web登录discord这样可以更好看一些信息
如何获取自己的discord服务器
#常规
MIDJOURNEY
文字频道
#常规
M
语音频道
常规
十
创建服务器
服务器是您和好友聚音的地方.创建您自己的服务
器,开始畅聊吧.
亲自创建
从模板开始
游戏
学校俱乐部
看入门步骤,帮助您
学习小组
入门指南.
已经有了邀请?
加入服务器
用图标个任化您的服务器
告诉我们更多关于您服务器的信息
为了帮助您进行设置,请回答您的新服务器是仅供几个朋
友使用,还是供更太的社区使用?
仅供我和我的朋友使用
供俱乐部或社区使用
还不确定?你可以暂时跳过该问题.
看入门步骤,
入门指南.
后退
邀请您的好友
自定义您的服务器
一个名称以及一个图标就能赋予您的服务器个性.之
后,您可以随时进行变更.
UPLOAD
服务器名称
MIDJOURNEY-TEST
您创建服务器即代表您同意了DISCORD的社区守则.
看入门步骤,
门指南.
创建
后退
最好创建一个自己的频道,用默认的也可以,自己创建的方便区分
MIDJOURNEY-TEST
吊规
文字频道
#常规
M-T
语音频道
M
常规
创建频道
于文字频道
频道类别
TEXT
发送消息,图片,GIF,表情符号,观点和梗
VOICE
一起来语音,视频和屏幕共享
频道名称
#TEST-ENV
ST
私密频道
入门步骤
门指南.
只有所选成员以及身份组才可查看此频道.
创建频道
取消
如果获取自己的机器人
https://discord.com/developers/applications
NEW APPLICATION
YOUR SERVER.GET STARTED BY CREATING A
LARGE
SMALL
CREATE AN APPLICATION
ARE YOU A GAME DEV?WE MAY ALREADY HAVE YOUR APP IN
OUR DATABASE.REACH OUT TO OUR DEV SUPPORT FOR MORE
YET,SADFACE.
INFO AND TO CLAIM YOUR GAME!
GET STARTED.
NAME
WRAPMIDJOURNEY
BY CLICKING CREATE,YOU AGREE TO
THE DISCORD DEVELOPER
TERMS OF SERVICE AND DEVELOPER POLICY.
CREATE
CANCEL
SELECTED APP
BRING-YOUR APP TO LIFE ON DISCORD WITH A BOT USER BE A PART OF CHAT IN YOUR SERVERS AND INTERACTL
WRAP-MIDJOURNEY
LEARN MORE ABOUT BOT USERS
GENERAL INFORMATION
BUILD-A-BOT
ADD BOT
BRING YOUR APP TO LIFE BY ADDING A BOT USER. THLS ACTION IS IRREVERSIBLE COBOTS ARE TOO COOL TO DESTR
BOT
BRING YOUR APP TO LIFE ON DISCORD WITH A BOT USER. BE A PART OF CHAT IN YOUR USERS SERVERS AND
LEARN MORE ABOUT BOT USERS
A WILD BOT HAS APPEARED!
BUILD-A-BOT
BRING YOUR APP TO LIFE BY ADDING A BOT USER THIS ACTION IS IRREVERSIBLE(BECAUSE ROBOTS ARE TO DESTROY
USERNAME
ICON
WRAPMIDJOURNEY
TOKEN
FOR SECURITY
IF URPOSES, TOKENS CAN ONIY BE VIEWED ONCE, WHEN CREATED. IF YOU FORGOT OR LOST ACCESS TO YOU
COPY
VIEW TOKEN
AUTHORIZATION FLOW
THESE SETTINGS CONTROL HOW OAUTHZ AUTHORIZATIONS ARE RESTRICTED FOR YOUR BOT(WHO CAN BOT AND HOW IT I
PUBLIC BOT
PUBLIC BOTS CAN BE ADDED BV ANVONE.WHEN UNCHECKED. ONLV YOU CAN IOIN THIS BOT TO SERVERVERS:
把这个token保存下来,这个token我们叫做bot token
NOTE:ONCE YOUR BOT REACHES 100 OR MORE SERVERS,THIS WILL REQUIRE VERIFFICATION AND APPROVAL READ MORE
SELECTED APP
WRAP-MIDJOURNEY
MESSAGE CONTENT INTENT
SETTINGS
REQUIRED FOR YOUR BOT TO RECEIVE MESSAGE CONTENT IN MOST MESSAGES.
GENERAL INFORMATION
NOTE: ONCE YOUR BOT REACHES 100 OR MORE SERVERS, THIS WILL REQUIRE VERIFFICATION APPROVAL.READ MORE
OAUTH2
BOT
目
RICH PRESENCE
BOT PERMISSIONS
NEED SOME HELD WITHBRT MATHY, USER FOR BARED BELOW TOR FOR FERMISSIONS NTEGER FOR BASED ON THE FES IT
APP TESTERS
VOICE PERMISSIONS
TEXT PERMISSIONS
CONNECT
ADMINISTRATOR
SEND MESSAGES
VIEW AUDIT LOG
CREATE PUBLIC THREADS
SPEAK
VIDEO
CREATE PRIVATE THREADS
MANAGE SERVER
MUTE MEMBERS
SEND MESSAGES IN THREADS
MANAGE ROLES
DEAFEN MEMBERS
SEND TTS MESSAGES
MANAGE CHANNELS
KICK MEMBERS
MOVE MEMBERS
MANAGE MESSAGES
USE VOICE ACTIVITY
BAN MEMBERS
MANAGE THREADS
PRIORITY SPEAKER
CREATE INSTANT INVITE
EMBED LINKS
REQUEST TO SPEAK
ATTACH FILES
CHANGE NICKNAME
USE EMBEDDED ACTIVITIE
READ MESSAGE HISTORY
MANAGE NICKNAMES
MENTION EVERYONE
USE SOUNDBOARD
MANAGE EMOJIS AND STICKERS
CREATE EMOJIS AND STICKERS
USE EXTERNAL EMOJIS
USE EXTERNAL SOUNDS
SELECTED APP
GENERATE AN INVTA TNKFOR JOUR APPLICATON BY DICKING THE SOOPES AND PERNISSIT NEEDS TO THER THER TO OT
WRAP-MIDJOURNEY
IDENTIFY
CONNECTIONS
RPC
URL GENERATOR
MESSAGES.READ
APPLLCATIONS,BULLDS.UPLOAD
APPLICATIONS COMMANDS
ACTIVITIES.READ
APPLICATIONS.ENTITLEMENTS
RICH PRESENCE
VBICE
APP TESTERS
GENERATED URL
COPY
PLEASE SELECT AT LEAST ONE OAUTH2 SCOPE
BACK TO APPLICATIONS
GUILDS
GUILDS.JOIN
GUILDS.MEMBERS.READ
WRAP-MIDJOURNEY
BOT
GENERAL INFORMATION
PPLICATIONS STARE.UPDATE
ACTIVITLES.READ
CAUTH2
VAICE
CIM_CHANNELS.READ
APPLICATIONS.COMMANDS.PERMISSIONS.UPDATE
BOT
TEXT PERMISSIONS
VOICE PERMISSIONS
RICH PRESENCE
SENDMESSAGE
CONNECT
SPEAK
VIDEO
MUTE MEMBERS
MANAGE ROLES
SEND MESSAGES IN THREADS
DEAFEN MEMBERS
MANAGE CHANNELS
KICK MEMBERS
USE VOICE ACTIVITY
PRIORITY SPEAKER
CREATE INSTANT INVITE
REQUEST TO SPEAK
USE EXTERNAL SOUNDS
CREATE EMOJIS AND STICKERS
USE EXTERNAL STICKERS
READ MESSAGES/VLEW CHANNELS
USE SLASH COMMANDS
MANAGE EVENTS
CREATE EVENTS
VLEW SERVER INSIGHTS
VIEW CREATOR MONETIZATION INSIGHTS
X
HOW SATISFIED ARE YOU WITH DEVELOPING
HTPR/DLISORDCOMN/ESUJH7/ENUTHORTERS333333333333333333333333333333333333333333333333333333333350RSCORD
然后点击copy按钮,粘贴到浏览器中,确认授权
外部应用程序
机器人
WRAPMIDJOURNEY
想访问您的DISCORD账户
正在以STACK#5832身份登录 不是本人?
这将会允许WRAP-MIDJOURNEY的开发人员:
在服务器中增加一个机器人
在服务器内创建指令
请你吃顿美味海鲜晚餐
添加至服务器:
MIDJOURNEY-TEST
这需要您拥有该服务器上的管理服务器权限.
继续
取消
选择正确的服务器
开启这个配置
BOT
SELECTED APP
BRING YOUR APP TO LIFE ON DISCORD WITH A BOT USER. BE A PART O
WRAPMIDJOURNEY
DIRECTLY.
SETTINGS
UT BOT USERS
LEARN MORE ABOUT B
GENERAL INFORMATION
BUILD-A-BOT
OAUTH2
BRING YOUR APP TO LIFE BY ADDING A BOT USER. THIS ACTION IS IRREVERSIBLE (BECAL
BOT
USERNAME
ICON
RICH PRESENCE
WRAPMIDJOURNEY
APP TESTERS
TOKEN
FOR SECURITY PURPOSES,TOKENS CAN ONLY BE VIEWED O
OAUTH2
NOTE: ONCE YOUR BOT REACHES 100 OR MORE SERVERS,THIS WILL REQUIRE VERIFICATION AND APPROVAL MORE HER
BOT
MESSAGE CONTENT INTENT
RICH PRESENCE
REQUIRED FOR YOUR BOT TO RECEIVE MESSAGE CONTENT IN MOST MESSAGES.
TESTERS
APP 1
NOTE: ONCE YOUR BOT REACHES 100 OR MORE SERVERS,THIS WILL REQUIRE VERIFICATION AND APPROVAL. RE HERE
如何使用postman或者web服务触发midjourney生图
首先需要把midjourney机器人引入到我们的服务器中
https://discord.com/invite/midjourney 这个是邀请地址,如果失效了可以点击开头中的链接,里面也有。
自从22:33以来有50条以上的新消息
M-T
机器人
今天22:33
MIDJOURNEY BOT
GENERA E A UNIQUE AND SPOOKY WATERCOLOR AL IMAGE OF A BABY DOG IN A GOTHIC STYLE WITH SHARP FANGS, PO
CAPE IS WELL-DEFINED. THE FINAL IMAGE SHOULD BE CAREFULLY ISOLATED ON A WHITE BACKGROUND TO MAKE IT E
主页
M
首2场活动
花频道和身份组
INFO
ANNOUNCEMENTS
RECENT-CHANGES
STATUS
RULES
GETTING-STARTED
SUPPORT
#TRIAL-SUPPORT
U4
U1
U2
U3
NEWCOMER ROOMS
V4
V1
V3
V2
NEWBIES-27
DESIGN A FAVORITE FLOWERPOT FOR THE AMERICAN MARKET/RELAX-@SAM198901 (FAST)
NEWCOMER ROOMS 2
NEWBIES-57
NEWBIES-87
AGEOF A BABY
CAREFULLY ISOLAT
MIDJOURNEY BOT#9282
机器人
添加至服务器
白我介绍
USE/IMAGINE TO GENERATE AN IMAGE IN UNDER 60
SECONDS,BASED ON A TEXT PROMPT!
成员注册时间
41
1月 29,2022
1月 29,2022
试试我的指令
/IMAGINE
/INFO
/BLEND
/SETTINGS
/SUBSCRIBE
身份组
MIDJOURNEY BOT
GROUP 45
WAVE 1
GROUP 57
外部应用程序
MIDJOURNEY BOT
机器人
想访问您的DISCORD账户
这将会允许MIDJOURNEY BOT的开发人员:
在服务器中增加一个机器人
在服务器内创建指令
录制新的混音带
添加至服务器:
MIDJOURNEY-TEST
这需要您拥有该服务器上的管理服务器权限.
继续
取消
先在频道内测试一下机器人是否可以正常运行
(目前免费版无法使用了。。。)
使用postman触发需要用户的登录token,获取方式
1打开开发者工具
2刷新界面
3查找一个library接口
4头部中的authorization的值就是你的用户token
X
NAME
PAYLOAD
HEADERS
TIMING
RESPONSE
PREVIEW
COOKIES
INITIATOR
RESPONSE HEADERS
/ASSETS
05422EB499DDF5616E44A52C4F10.
ALT-SVC:H3-":443";MA-86400,H3-29-":443";MA-86400
/ASSETS
CF-CACHE-STATUS: DYNAMIC
CF-RAY:7B53906B3A0E6C5F-SIN
UPCOMING.JSON
STATUS.DISCORD.COM/API/V2/SCHEDU.
CONTENT-LENGTH : 2
LIBRARY7COUNTRY_CODE-US
CONTENT-TYPE: APPLICATION/JSON
API/V9/USERS/@ME
DATE: SUN, 09 APR 2023 14:50:44 GM
14 GMT
NEL: {'SUCCESS_FRACTION":0,"REPORT_TO":"CF-NEL","MAX_AGE":604800}
ELLGIBILITY
API/V9/CREATOR-MONETIZATION/MARK.
REPORT-TO: ""ENDPOINTS":{"URL";"HTTPS:\/AINEL.CLOUDFLARE.CLOUDFLARE.COM//REPORT\/V375-UN多2620UKA
SJETFVF9TTED45XURDX27HIOVANIZ9OZKNNI3UFJH880PQEZFWHI' IL,"GROUP":"(F-NEL","MAX -AGE":604800>
MESSAGES?LIMIT-50
/API/V9/CHANNELS/1094614243753.
SERVER: CLOUDFLARE
DETECTABLE
STRICT-TRANSPORT-SECURITY: MAX-AGE-31536000; INCLUDESUBDOMAINS; PRELOAD
/API/V9/APPLICATIONS
VIA:1.1 GOOGLE
FABE5167F413A48CBBE1.WORKER.JS
X-CONTENT-TYPE-OPTIONS:NOSNIFF
/ASSETS
REQUEST HEADERS
515D0236BCE3BA834026209DC78.
AUTHORITY: DISCORD.COM
/ASSETS
:METHOD:GET
35827C42A3AF54BD169CFF0A866EB
PATH://API/V9/USERS/@ME/LIBRARY?COUNTRY_CODE-US
/ASSETS
SCHEME:HTTPS
A532E755C36B75762A75FF079445.
ACCEPT:*/*
/ASSETS
ACCEPT-ENCODING:GZIP,DEFLATE,BR
3B560ACDC7FCF50D1BF8388ACA8E..
/ASSETS
ACCEPT-LANGUAGE:ZH-CN,ZH:GH:G,EN;Q-0.8
AUTHORIZATIOR
4DFCBF879AC5C3BDB6D3829F3B99.
/ASSETS
CACHE-CONTROL:NO-CACHE
(COOKLE: -DCFDUID-21CD5B44D1511LEDBEBBF63BC43D3D3DAF; -SDCFDUID-Z1CD5644D1511LEDBEBBR636C43D3
6B9558EC980450474680.JS
/ASSETS
AA6; -CFRUID-83D5A681LEA420BFF875901BI3EAO3DIE60C87F3-1681051838; -CF--CF-BM--WFJDVN7AMHCTIXO
5E+GO/BDZUTW/IVITBENPMOSAQMA43YO7AQELBJBDIHNCSI8EJXMEVOLF9MQZNDAUVQYKZWF91T+KCTA93UOENCZC8Y
71F6572FF1B702B988A1.JS
/ASSETS
PRAGMA:NO-CACHE
KANNGLC/1AOA613721554374776/1G94614242753611335
WFAWNS HTTNE.//DI
获取指令调用的接口和对应的参数,在频道中输入指令,并进行触发的时候,查看控制台有个https://discord.com/api/v9/interactions接口,就是指令触发接口,payload中有请求参数,需要注意的是使用其它方式调用的时候使用application/json
EINITIATORTIMINGCOOKIES
RESPONSEINI
PAYLOAD
PREVIEW
HEADERS
7C8F476123D28D103EFE38154327...
FORM DATA
VIEW DECODED
VIEW SOURCE
/ASSETS
4A79EA7CD151474FF9F6E08339D69...
CDN.DISCORDAPP.COM/AVATARS/936...
SAC55ZAC666CEL NORESSION, ASSCEECEL
INTERACTIONS
/API/V9
RIPTION"""THE PROMPT TO INAGINE","REQUIRED";TRUERJ),"ATTACHMENTS":(1):"NONCE","1094636173814398978"
DD920C00A010556009678581E2...
/ASSETS
7C81476123D28D103EFE38154327...
/ASSETS
4A79EA7CD151474FF9F6E08339D69...
CDN.DISCORDAPP.COM/AVATARS/936...
SEARCH?TYPE1&LIMIT-0&COMMAN...
/API/V9/CHANNELS/1094614243753...
SEND
HTTPS://DISCORD.COM/API/V9/INTERACTIONS
POST
PRE-REQUEST SCRIPT
SETTINGS
AUTHORIZATION
BODY
TESTS
PARAMS
HEADERS(10)
POSTMAN-TOKEN
<CALCULATED WHEN REQUEST IS SENT>
CONTENT-TYPE
APPLICATION/JSON
<CALCULATED WHEN REQUEST IS SENT>
CONTENT-LENGTH
<CALCULATED WHEN REQUEST IS SENT>
HOST
POSTMANRUNTIME/7.28.1
USER-AGENT
ACCEPT
ACCEPT-ENCODING
GZIP,DEFLATE,BR
CONNECTION
KEEP-ALIVE
MTA5NDQ4NTKONTCYMZY 1MDE1MA.GSLZ-I.LMPA...
AUTHORIZATION
DESCRIPTION
VALUE
KEY
COOKIES.(3)
HEADERS (1
注意:请求参数中有一个noce字段,这个字段记得删掉,不然调用后无法触发
请求参数分析
你的服务器id和频道id来源
HTTPS://DISCORD.COM/CHANNELS/1094613721554374776/1094614243753611335
如何获取discord服务器中的midjourney生图结果
详细看代码 GitHub - Can-Chen/wrap-midjourney: 获取discord服务器中midjourney AI生图的结果。一个中转服务,可以接入到任意第三方平台微信、飞书、QQ等/Obtain the midjourney AI image generation results from the Discord server. It is a transfer service that can be connected to any third-party platform, such as WeChat, Feishu, QQ, etc.
回调地址接口
●你的地址
●post请求
参数
字段
类型
是否必填
说明
type
string
是
值为GenerateEnd为接收到生图完成
content
string
否
值不为GenerateEnd为必填项,你发送给discord的prompt
discord
discord.MessageCreate
否
值为GenerateEnd时必填项,包含你所需的图片信息
这个服务收到discord的消息的更新后会调用这个接口
如何利用这个项目触发生图
按照项目中的配置好所需的信息后,启动这个go项目,调试直接用 go run main.go就好了,部署推荐找一个守护进程的库就好了。
获取到MIDJOURNEY机器人给的反馈
调用你配置的地址
WRAP-MIDJOURNEY服务
你自己的服务
(中间服务)
调用中间服务
POST LOCALHOST:16007/V1/TRIGGER/MIDJOURNEY-BOT
JSON复制代码
Post
Url: BaseURL + /v1/trigger/midjourney-bot
Request Body
{
// generate代表生图
// upscale 选中对应的图片变大
// variation 选中其中的一张图,生成四张相似的
// reset 按照你的提示词重新生成
// maxupscale upscale后只有一张图返回,此时你是使用这张图再生成四张类似的
"type": "generate",
// 进行 upscale、variation、reset、maxupscale操作的时候必传 来源是生图结果回调中的discord字段中的messageId
"discordMsgId": "",
// 进行 upscale、variation、reset、maxupscale操作的时候必传 来源是生图结果回调中的图片地址函数操作 attachments[0].url.split("_")[-1]).split(".")[0]
"msgHash": "",
// 进行 generate操作必传
"prompt": "",
// 进行 upscale、variation操作必传
"index": 0
}
调用你的回调Request Body请看 回调地址接口