Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions api/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -180,14 +182,16 @@ 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")
}
sum += e.Length()
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
}
}

Expand Down Expand Up @@ -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
}
}

Expand All @@ -247,14 +253,16 @@ 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")
}
sum += e.Length()
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
}
}

Expand Down
5 changes: 4 additions & 1 deletion api/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 3 additions & 1 deletion api/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down