-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
61 lines (47 loc) · 1.29 KB
/
client.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
package midjourney
import (
"context"
"net/http"
)
type Client struct {
APIURL string
ChannelID string
AuthenticationToken string
GuildID string
UserID string
MidJourneyApplicationID string
MidJourneyDataID string
MidJourneyDataVersion string
MidJourneySessionID string
HTTPClient *http.Client
}
type ClientOpts = func(client *Client) error
func NewClient(ctx context.Context, authenticationToken string, channelID string, opts ...ClientOpts) (*Client, error) {
client := &Client{
APIURL: "https://discord.com/api/v9",
ChannelID: channelID,
AuthenticationToken: authenticationToken,
HTTPClient: http.DefaultClient,
MidJourneyApplicationID: "936929561302675456",
MidJourneyDataID: "938956540159881230",
MidJourneyDataVersion: "1118961510123847772",
MidJourneySessionID: "2fb980f65e5c9a77c96ca01f2c242cf6",
}
channel, err := client.Channel(ctx, channelID)
if err != nil {
return nil, err
}
client.GuildID = channel.GuildID
me, err := client.Me(ctx)
if err != nil {
return nil, err
}
client.UserID = me.ID
for _, option := range opts {
err := option(client)
if err != nil {
return nil, err
}
}
return client, nil
}