try adding "author" to embed

This commit is contained in:
Seraphim Strub 2024-06-06 19:32:23 +00:00
parent d233ae17ff
commit d6a03db2aa

View file

@ -16,6 +16,7 @@ import (
"os"
"os/signal"
"reflect"
"strings"
"syscall"
"time"
)
@ -122,12 +123,30 @@ func sendWebhook(client webhook.Client, deal api.Deal) {
if deal.Image == "" {
message.SetContent(fmt.Sprintf("%v %v\n", content, deal.Url))
} else {
message.SetContent(content).SetEmbeds(
discord.NewEmbedBuilder().
embed := discord.NewEmbedBuilder().
SetTitle(deal.Title).
SetURL(deal.Url).
SetImage(deal.Image).
Build())
SetImage(deal.Image)
var author, icon string
switch {
case strings.HasPrefix(deal.Id, "epic-"):
author = "Epic Games"
icon = "https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Epic_Games_logo.svg/207px-Epic_Games_logo.svg.png"
case strings.HasPrefix(deal.Id, "gog-"):
author = "GOG.com"
icon = "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2e/GOG.com_logo.svg/391px-GOG.com_logo.svg.png"
case strings.HasPrefix(deal.Id, "humblebundle-"):
author = "Humble Bundle"
icon = "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Humble_Bundle_logo.svg/320px-Humble_Bundle_logo.svg.png"
case strings.HasPrefix(deal.Id, "steam-"):
author = "Steam"
icon = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Steam_icon_logo.svg/240px-Steam_icon_logo.svg.png"
case strings.HasPrefix(deal.Id, "ubisoft-"):
author = "Ubisoft"
icon = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/78/Ubisoft_logo.svg/262px-Ubisoft_logo.svg.png"
}
embed.SetAuthor(author, "", icon)
message.SetContent(content).SetEmbeds(embed.Build())
}
if _, err := client.CreateMessage(message.Build(),