FILE / Unmei/Backend
v1/discord.go
Исходный файл и его история в репозитории.
32 lines
642 B
Go
32 lines
642 B
Go
package v1
|
|
|
|
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
|
|
}
|