aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-10-08 18:55:45 -0400
committerXe Iaso <me@xeiaso.net>2023-10-08 18:55:45 -0400
commit025bfd82cc270bfc502bc8a61b978b0a3e3e8d6b (patch)
treeb026adf827e71575b2b7eeb41def4dd5673be15d /web
parent777393ad4ebbc1956abc6530c4f8499356c9a719 (diff)
downloadx-025bfd82cc270bfc502bc8a61b978b0a3e3e8d6b.tar.xz
x-025bfd82cc270bfc502bc8a61b978b0a3e3e8d6b.zip
cmd/sapientwindex: adapt into being a tool for goodv1.8.0
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'web')
-rw-r--r--web/discordwebhook/webhook.go27
1 files changed, 19 insertions, 8 deletions
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