mirror of
https://github.com/idanoo/NZCovidBot
synced 2025-07-02 03:32:14 +00:00
- Build cache based on row data instead of entire row - Compare columns instead of entire row - Removed commitHash check and instead just processes on succesfull git pull - No more entire file dumps!
39 lines
671 B
Go
39 lines
671 B
Go
package nzcovidbot
|
|
|
|
import (
|
|
"log"
|
|
"strings"
|
|
|
|
"github.com/DisgoOrg/disgohook"
|
|
"github.com/DisgoOrg/disgohook/api"
|
|
)
|
|
|
|
// Slice of discord webhooks
|
|
var DiscordWebhooks []string
|
|
|
|
func postToDiscord(webhookString string, msg string) {
|
|
if webhookString == "" {
|
|
return
|
|
}
|
|
|
|
tokenParts := strings.Split(webhookString, "/")
|
|
len := len(tokenParts)
|
|
webhook, err := disgohook.NewWebhookClientByToken(nil, nil, tokenParts[len-2]+"/"+tokenParts[len-1])
|
|
if err != nil {
|
|
log.Print(err)
|
|
return
|
|
}
|
|
|
|
_, err = webhook.SendEmbeds(api.NewEmbedBuilder().
|
|
SetDescription(msg).
|
|
Build(),
|
|
)
|
|
if err != nil {
|
|
log.Print(err)
|
|
return
|
|
}
|
|
|
|
if err != nil {
|
|
log.Print(err)
|
|
}
|
|
}
|