From 025bfd82cc270bfc502bc8a61b978b0a3e3e8d6b Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sun, 8 Oct 2023 18:55:45 -0400 Subject: cmd/sapientwindex: adapt into being a tool for good Signed-off-by: Xe Iaso --- web/discordwebhook/webhook.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'web/discordwebhook') diff --git a/web/discordwebhook/webhook.go b/web/discordwebhook/webhook.go index c09b89c..f6fec3c 100644 --- a/web/discordwebhook/webhook.go +++ b/web/discordwebhook/webhook.go @@ -11,10 +11,11 @@ import ( // Webhook is the parent structure fired off to Discord. type Webhook struct { - Content string `json:"content,omitifempty"` - Username string `json:"username"` - AvatarURL string `json:"avatar_url"` - Embeds []Embeds `json:"embeds,omitifempty"` + Content string `json:"content,omitempty"` + Username string `json:"username,omitempty"` + AvatarURL string `json:"avatar_url"` + Embeds []Embeds `json:"embeds,omitempty"` + AllowedMentions map[string][]string `json:"allowed_mentions"` } // EmbedField is an individual field being embedded in a message. @@ -32,8 +33,18 @@ type EmbedFooter struct { // Embeds is a set of embed fields and a footer. type Embeds struct { - Fields []EmbedField `json:"fields"` - Footer EmbedFooter `json:"footer"` + Title string `json:"title,omitempty"` + Description string `json:"description,omitempty"` + URL string `json:"url,omitempty"` + Author *EmbedAuthor `json:"author,omitempty"` + Fields []EmbedField `json:"fields,omitempty"` + Footer *EmbedFooter `json:"footer,omitempty"` +} + +type EmbedAuthor struct { + Name string `json:"name"` + URL string `json:"url"` + IconURL string `json:"icon_url"` } // Send returns a request for a Discord webhook. @@ -59,8 +70,8 @@ func Send(whurl string, w Webhook) *http.Request { // Validate validates the response from Discord. func Validate(resp *http.Response) error { - if resp.StatusCode != http.StatusOK { - return web.NewError(http.StatusOK, resp) + if resp.StatusCode != http.StatusNoContent { + return web.NewError(http.StatusNoContent, resp) } return nil -- cgit v1.2.3