代码拉取完成,页面将自动刷新
package midjourney
import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"
)
type LowVariationRequest struct {
Index int32 `json:"index"`
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id"`
MessageID string `json:"message_id"`
MessageHash string `json:"message_hash"`
}
func (c *Client) LowVariation(ctx context.Context, variationReq *LowVariationRequest) error {
flags := 0
interactionsReq := &InteractionsRequest{
Type: 3,
ApplicationID: ApplicationID,
GuildID: variationReq.GuildID,
ChannelID: variationReq.ChannelID,
MessageFlags: &flags,
MessageID: &variationReq.MessageID,
SessionID: SessionID,
Data: map[string]any{
"component_type": 2,
"custom_id": fmt.Sprintf("MJ::JOB::low_variation::%d::%s::SOLO", variationReq.Index, variationReq.MessageHash),
},
}
b, _ := json.Marshal(interactionsReq)
url := "https://discord.com/api/v9/interactions"
req, err := http.NewRequest("POST", url, bytes.NewReader(b))
if err != nil {
return fmt.Errorf("Call http.NewRequest failed, err: %w", err)
}
req.Header.Set("Authorization", c.Config.UserToken)
req.Header.Set("Content-Type", "application/json")
resp, err := c.Do(req)
if err != nil {
return fmt.Errorf("Call c.Do failed, err: %w", err)
}
defer resp.Body.Close()
if err := checkResponse(resp); err != nil {
return fmt.Errorf("Call checkResponse failed, err: %w", err)
}
return nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。