mi-v1/cmd/mi/discordwebhook.go

27 lines
516 B
Go

package main
import (
"context"
"flag"
"net/http"
"within.website/x/web/discordwebhook"
)
var (
discordWebhook = flag.String("discord-webhook", "", "Discord webhook to announce new posts to")
)
func (mi *Mi) PushDiscordWebhook(ctx context.Context, p Post) error {
w := discordwebhook.Webhook{
Content: p.Format(),
Username: "Cadey's Blog",
AvatarURL: "https://christine.website/static/img/avatar.png",
}
req := discordwebhook.Send(*discordWebhook, w)
http.DefaultClient.Do(req)
return nil
}