forked from pothtonswer/discordmuffin
Make update status a little more idiomatic.
This also reduces the line count a smidge.
This commit is contained in:
parent
bb4f63775e
commit
974d5862a4
1 changed files with 6 additions and 13 deletions
19
wsapi.go
19
wsapi.go
|
@ -60,12 +60,12 @@ func (s *Session) Handshake() (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type updateStatusGame struct {
|
type updateStatusGame struct {
|
||||||
Name string `json:"name"`
|
Name *string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type updateStatusData struct {
|
type updateStatusData struct {
|
||||||
IdleSince json.Token `json:"idle_since"`
|
IdleSince *int `json:"idle_since"`
|
||||||
Game interface{} `json:"game"`
|
Game updateStatusGame `json:"game"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type updateStatusOp struct {
|
type updateStatusOp struct {
|
||||||
|
@ -80,17 +80,10 @@ func (s *Session) UpdateStatus(idle int, game string) (err error) {
|
||||||
|
|
||||||
var usd updateStatusData
|
var usd updateStatusData
|
||||||
if idle > 0 {
|
if idle > 0 {
|
||||||
usd.IdleSince = idle
|
usd.IdleSince = &idle
|
||||||
} else {
|
|
||||||
usd.IdleSince = nil
|
|
||||||
}
|
}
|
||||||
|
if game != "" {
|
||||||
var usg updateStatusGame
|
usd.Game.Name = &game
|
||||||
if game == "" {
|
|
||||||
usd.Game = nil
|
|
||||||
} else {
|
|
||||||
usg.Name = game
|
|
||||||
usd.Game = usg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data := updateStatusOp{3, usd}
|
data := updateStatusOp{3, usd}
|
||||||
|
|
Loading…
Reference in a new issue