mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-02-12 14:33:26 +00:00
api: Mutate validated embeds from discord.Embed.Validate (#271)
This commit is contained in:
parent
1e9eb4a473
commit
f334491dee
|
@ -123,6 +123,8 @@ func (c *Client) RespondInteraction(
|
|||
if sum > 6000 {
|
||||
return &discord.OverboundError{Count: sum, Max: 6000, Thing: "sum of all text in embeds"}
|
||||
}
|
||||
|
||||
(*resp.Data.Embeds)[i] = embed // embed.Validate changes fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +182,7 @@ func (c *Client) EditInteractionResponse(
|
|||
|
||||
if data.Embeds != nil {
|
||||
sum := 0
|
||||
for _, e := range *data.Embeds {
|
||||
for i, e := range *data.Embeds {
|
||||
if err := e.Validate(); err != nil {
|
||||
return nil, errors.Wrap(err, "embed error")
|
||||
}
|
||||
|
@ -188,6 +190,8 @@ func (c *Client) EditInteractionResponse(
|
|||
if sum > 6000 {
|
||||
return nil, &discord.OverboundError{Count: sum, Max: 6000, Thing: "sum of text in embeds"}
|
||||
}
|
||||
|
||||
(*data.Embeds)[i] = e // e.Validate changes fields
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,6 +231,8 @@ func (c *Client) CreateInteractionFollowup(
|
|||
if sum > 6000 {
|
||||
return nil, &discord.OverboundError{Count: sum, Max: 6000, Thing: "sum of all text in embeds"}
|
||||
}
|
||||
|
||||
(*data.Embeds)[i] = embed // embed.Validate changes fields
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +253,7 @@ func (c *Client) EditInteractionFollowup(
|
|||
|
||||
if data.Embeds != nil {
|
||||
sum := 0
|
||||
for _, e := range *data.Embeds {
|
||||
for i, e := range *data.Embeds {
|
||||
if err := e.Validate(); err != nil {
|
||||
return nil, errors.Wrap(err, "embed error")
|
||||
}
|
||||
|
@ -255,6 +261,8 @@ func (c *Client) EditInteractionFollowup(
|
|||
if sum > 6000 {
|
||||
return nil, &discord.OverboundError{Count: sum, Max: 6000, Thing: "sum of text in embeds"}
|
||||
}
|
||||
|
||||
(*data.Embeds)[i] = e // e.Validate changes fields
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -382,10 +382,13 @@ func (c *Client) EditMessageComplex(
|
|||
}
|
||||
sum += embed.Length()
|
||||
if sum > 6000 {
|
||||
return nil, &discord.OverboundError{sum, 6000, "sum of all text in embeds"}
|
||||
return nil, &discord.OverboundError{Count: sum, Max: 6000, Thing: "sum of all text in embeds"}
|
||||
}
|
||||
|
||||
(*data.Embeds)[i] = embed // embed.Validate changes fields
|
||||
}
|
||||
}
|
||||
|
||||
var msg *discord.Message
|
||||
return msg, sendpart.PATCH(c.Client, data, &msg,
|
||||
EndpointChannels+channelID.String()+"/messages/"+messageID.String())
|
||||
|
|
|
@ -168,8 +168,10 @@ func (c *Client) SendMessageComplex(
|
|||
}
|
||||
sum += embed.Length()
|
||||
if sum > 6000 {
|
||||
return nil, &discord.OverboundError{sum, 6000, "sum of all text in embeds"}
|
||||
return nil, &discord.OverboundError{Count: sum, Max: 6000, Thing: "sum of all text in embeds"}
|
||||
}
|
||||
|
||||
data.Embeds[i] = embed // embed.Validate changes fields
|
||||
}
|
||||
|
||||
var URL = EndpointChannels + channelID.String() + "/messages"
|
||||
|
|
Loading…
Reference in a new issue