mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-11-01 23:25:19 +00:00
Gateway: Changed UpdateStatus to be more valid
This commit is contained in:
parent
f71852604b
commit
b5f7af70f3
|
|
@ -25,6 +25,7 @@ func NowTimestamp() Timestamp {
|
|||
return NewTimestamp(time.Now())
|
||||
}
|
||||
|
||||
// UnmarshalJSON parses a nullable RFC3339 string into time.
|
||||
func (t *Timestamp) UnmarshalJSON(v []byte) error {
|
||||
str := strings.Trim(string(v), `"`)
|
||||
if str == "null" {
|
||||
|
|
@ -40,6 +41,8 @@ func (t *Timestamp) UnmarshalJSON(v []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// MarshalJSON returns null if Timestamp is not valid (zero). It returns the
|
||||
// time formatted in RFC3339 otherwise.
|
||||
func (t Timestamp) MarshalJSON() ([]byte, error) {
|
||||
if !t.Valid() {
|
||||
return []byte("null"), nil
|
||||
|
|
|
|||
|
|
@ -88,9 +88,10 @@ func (g *Gateway) UpdateVoiceState(data UpdateVoiceStateData) error {
|
|||
}
|
||||
|
||||
type UpdateStatusData struct {
|
||||
Since discord.UnixMsTimestamp `json:"since"` // 0 if not idle
|
||||
Game *discord.Activity `json:"game,omitempty"` // nullable
|
||||
Activities []discord.Activity `json:"activities,omitempty"`
|
||||
Since discord.UnixMsTimestamp `json:"since"` // 0 if not idle
|
||||
|
||||
Game *discord.Activity `json:"game,omitempty"` // nullable
|
||||
Activities *[]discord.Activity `json:"activities,omitempty"`
|
||||
|
||||
Status discord.Status `json:"status"`
|
||||
AFK bool `json:"afk"`
|
||||
|
|
|
|||
1
go.mod
1
go.mod
|
|
@ -4,6 +4,7 @@ go 1.13
|
|||
|
||||
require (
|
||||
github.com/gorilla/schema v1.1.0
|
||||
github.com/klauspost/compress v1.10.3 // indirect
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/sasha-s/go-csync v0.0.0-20160729053059-3bc6c8bdb3fa
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect
|
||||
|
|
|
|||
2
go.sum
2
go.sum
|
|
@ -15,6 +15,8 @@ github.com/gorilla/schema v1.1.0 h1:CamqUDOFUBqzrvxuz2vEwo8+SUdwsluFh7IlzJh30LY=
|
|||
github.com/gorilla/schema v1.1.0/go.mod h1:kgLaKoK1FELgZqMAVxx/5cbj0kT+57qxUrAlIO2eleU=
|
||||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eTO0Q8=
|
||||
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
|
|
|
|||
Loading…
Reference in a new issue