-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagine_prompt.go
67 lines (59 loc) · 1.56 KB
/
imagine_prompt.go
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package midjourney
import (
"context"
"encoding/json"
"fmt"
"net/http"
)
func (c *Client) ImaginePrompt(ctx context.Context, prompt string) error {
fmt.Printf("imagining: %v\n", prompt)
payload := InteractionPayload[ImaginePayloadData]{
Type: 2,
ApplicationID: c.MidJourneyApplicationID,
GuildID: c.GuildID,
ChannelID: c.ChannelID,
SessionID: c.MidJourneySessionID,
Data: ImaginePayloadData{
Version: c.MidJourneyDataVersion,
ID: c.MidJourneyDataID,
Name: "imagine",
Type: 1,
Options: []ImaginePayloadDataOption{
{
Type: 3,
Name: "prompt",
Value: prompt,
},
},
ApplicationCommand: ImaginePayloadDataApplicationCommand{
ID: c.MidJourneyDataID,
ApplicationID: c.MidJourneyApplicationID,
Version: c.MidJourneyDataVersion,
DefaultMemberPermissions: nil,
Type: 1,
NSFW: false,
Name: "imagine",
Description: "Create images with Midjourney",
DMPermission: true,
Options: []ImaginePayloadDataApplicationCommandOption{
{
Type: 3,
Name: "prompt",
Description: "the prompt to imagine",
Required: true,
},
},
},
},
}
fmt.Printf("payload: %+v\n", payload)
payloadRequest, err := json.Marshal(payload)
if err != nil {
return err
}
err = c.Request(ctx, http.MethodPost, Endpoint_Interactions, &payloadRequest, nil)
if err != nil {
return err
}
return nil
}