diff --git a/structs.go b/structs.go index 87ebe1d..198ff79 100644 --- a/structs.go +++ b/structs.go @@ -12,6 +12,7 @@ package discordgo import ( + "encoding/json" "net/http" "sync" "time" @@ -338,8 +339,23 @@ type Game struct { // A TimeStamps struct contains start and end times used in the rich presence "playing .." Game type TimeStamps struct { - EndTimestamp uint `json:"end,omitempty"` - StartTimestamp uint `json:"start,omitempty"` + EndTimestamp int64 `json:"end,omitempty"` + StartTimestamp int64 `json:"start,omitempty"` +} + +// UnmarshalJSON unmarshals JSON into TimeStamps struct +func (t *TimeStamps) UnmarshalJSON(b []byte) error { + temp := struct { + End float64 `json:"end,omitempty"` + Start float64 `json:"start,omitempty"` + }{} + err := json.Unmarshal(b, &temp) + if err != nil { + return err + } + t.EndTimestamp = int64(temp.End) + t.StartTimestamp = int64(temp.Start) + return nil } // An Assets struct contains assets and labels used in the rich presence "playing .." Game