fix: showModal
This commit is contained in:
parent
15fe432feb
commit
aaf5246218
1 changed files with 3 additions and 32 deletions
|
@ -97,37 +97,8 @@ func (i *InteractionCreate) ShowModal(data *ModalData) error {
|
||||||
|
|
||||||
reqData.Type = discordgo.InteractionResponseModal
|
reqData.Type = discordgo.InteractionResponseModal
|
||||||
reqData.Data = *data
|
reqData.Data = *data
|
||||||
bin, err := json.Marshal(reqData)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
buf := bytes.NewBuffer(bin)
|
endpoint := discordgo.EndpointInteractionResponse(i.ID, i.Token)
|
||||||
|
_, err := i.Session.RequestWithBucketID("POST", endpoint, reqData, endpoint)
|
||||||
req, err := http.NewRequest("POST", discordgo.EndpointInteractionResponse(i.ID, i.Token), buf)
|
return err
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Add("Authorization", i.Session.Identify.Token)
|
|
||||||
req.Header.Add("Content-Type", "application/json")
|
|
||||||
|
|
||||||
resp, err := i.Session.Client.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
respBin, err := io.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
|
||||||
return fmt.Errorf("%s", string(respBin))
|
|
||||||
}
|
|
||||||
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
i.Replied = true
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue