1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-30 18:53:30 +00:00

API: verify Embed and AllowedMentions on message edit

This commit is contained in:
mavolin 2020-05-25 01:56:41 +02:00 committed by diamondburned
parent 55e9c28d37
commit 6c3b1e0c56

View file

@ -1,6 +1,8 @@
package api
import (
"github.com/pkg/errors"
"github.com/diamondburned/arikawa/discord"
"github.com/diamondburned/arikawa/utils/httputil"
"github.com/diamondburned/arikawa/utils/json/option"
@ -258,6 +260,18 @@ func (c *Client) EditMessage(
func (c *Client) EditMessageComplex(
channelID, messageID discord.Snowflake, data EditMessageData) (*discord.Message, error) {
if data.AllowedMentions != nil {
if err := data.AllowedMentions.Verify(); err != nil {
return nil, errors.Wrap(err, "allowedMentions error")
}
}
if data.Embed != nil {
if err := data.Embed.Validate(); err != nil {
return nil, errors.Wrap(err, "embed error")
}
}
var msg *discord.Message
return msg, c.RequestJSON(
&msg, "PATCH",