Skip to content

Commit

Permalink
feat: add hostname to discord message
Browse files Browse the repository at this point in the history
  • Loading branch information
mlcdf committed Apr 25, 2021
1 parent c8f2d6b commit 49409da
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions internal/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"os"
"time"
)

Expand Down Expand Up @@ -61,6 +62,17 @@ type Image struct {
URL string `json:"url"`
}

var hostname string

func init() {
var err error

hostname, err = os.Hostname()
if err != nil {
hostname = "(unknown)"
}
}

func (c *Client) PostError(webhook *Webhook) error {
webhook.Embeds[0].Color = 15092300
return c.Post(webhook)
Expand All @@ -73,6 +85,7 @@ func (c *Client) PostSuccess(webhook *Webhook) error {

func (c *Client) Post(webhook *Webhook) error {
webhook.Embeds[0].TimeStamp = time.Now().UTC().Format(time.RFC3339)
webhook.Embeds[0].Footer.Text = hostname

payload, err := json.Marshal(webhook)
if err != nil {
Expand Down

0 comments on commit 49409da

Please sign in to comment.