FILE / Unmei/Backend

utils/discord.go

Исходный файл и его история в репозитории.
FILE main
Files
2025-03-12 16:30:40 +03:00

32 lines
645 B
Go

package utils
import (
"bytes"
"encoding/json"
"net/http"
"time"
)
type Embed struct {
Title string `json:"title"`
Type string `json:"type"`
Description string `json:"description"`
URL string `json:"url"`
Timestamp time.Time `json:"timestamp"`
Color uint32 `json:"color"`
}
type WebhookContent struct {
Content string `json:"content"`
Embeds []Embed `json:"embeds"`
}
func ExecuteWebhook(url string, content WebhookContent) error {
body, err := json.Marshal(content)
if err != nil {
return err
}
_, err = http.Post(url, "application/json", bytes.NewReader(body))
return err
}