|
@@ -322,10 +322,10 @@ func (s *Session) heartbeat(wsConn *websocket.Conn, listening <-chan interface{}
|
|
|
|
|
|
// UpdateStatusData ia provided to UpdateStatusComplex()
|
|
// UpdateStatusData ia provided to UpdateStatusComplex()
|
|
type UpdateStatusData struct {
|
|
type UpdateStatusData struct {
|
|
- IdleSince *int `json:"since"`
|
|
|
|
- Game *Game `json:"game"`
|
|
|
|
- AFK bool `json:"afk"`
|
|
|
|
- Status string `json:"status"`
|
|
|
|
|
|
+ IdleSince *int `json:"since"`
|
|
|
|
+ Activities []*Activity `json:"activities"`
|
|
|
|
+ AFK bool `json:"afk"`
|
|
|
|
+ Status string `json:"status"`
|
|
}
|
|
}
|
|
|
|
|
|
type updateStatusOp struct {
|
|
type updateStatusOp struct {
|
|
@@ -333,7 +333,7 @@ type updateStatusOp struct {
|
|
Data UpdateStatusData `json:"d"`
|
|
Data UpdateStatusData `json:"d"`
|
|
}
|
|
}
|
|
|
|
|
|
-func newUpdateStatusData(idle int, gameType GameType, game, url string) *UpdateStatusData {
|
|
|
|
|
|
+func newUpdateStatusData(idle int, activityType ActivityType, name, url string) *UpdateStatusData {
|
|
usd := &UpdateStatusData{
|
|
usd := &UpdateStatusData{
|
|
Status: "online",
|
|
Status: "online",
|
|
}
|
|
}
|
|
@@ -342,12 +342,12 @@ func newUpdateStatusData(idle int, gameType GameType, game, url string) *UpdateS
|
|
usd.IdleSince = &idle
|
|
usd.IdleSince = &idle
|
|
}
|
|
}
|
|
|
|
|
|
- if game != "" {
|
|
|
|
- usd.Game = &Game{
|
|
|
|
- Name: game,
|
|
|
|
- Type: gameType,
|
|
|
|
|
|
+ if name != "" {
|
|
|
|
+ usd.Activities = []*Activity{{
|
|
|
|
+ Name: name,
|
|
|
|
+ Type: activityType,
|
|
URL: url,
|
|
URL: url,
|
|
- }
|
|
|
|
|
|
+ }}
|
|
}
|
|
}
|
|
|
|
|
|
return usd
|
|
return usd
|
|
@@ -355,30 +355,30 @@ func newUpdateStatusData(idle int, gameType GameType, game, url string) *UpdateS
|
|
|
|
|
|
// UpdateStatus is used to update the user's status.
|
|
// UpdateStatus is used to update the user's status.
|
|
// If idle>0 then set status to idle.
|
|
// If idle>0 then set status to idle.
|
|
-// If game!="" then set game.
|
|
|
|
-// if otherwise, set status to active, and no game.
|
|
|
|
-func (s *Session) UpdateStatus(idle int, game string) (err error) {
|
|
|
|
- return s.UpdateStatusComplex(*newUpdateStatusData(idle, GameTypeGame, game, ""))
|
|
|
|
|
|
+// If name!="" then set game.
|
|
|
|
+// if otherwise, set status to active, and no activity.
|
|
|
|
+func (s *Session) UpdateGameStatus(idle int, name string) (err error) {
|
|
|
|
+ return s.UpdateStatusComplex(*newUpdateStatusData(idle, ActivityTypeGame, name, ""))
|
|
}
|
|
}
|
|
|
|
|
|
// UpdateStreamingStatus is used to update the user's streaming status.
|
|
// UpdateStreamingStatus is used to update the user's streaming status.
|
|
// If idle>0 then set status to idle.
|
|
// If idle>0 then set status to idle.
|
|
-// If game!="" then set game.
|
|
|
|
-// If game!="" and url!="" then set the status type to streaming with the URL set.
|
|
|
|
|
|
+// If name!="" then set game.
|
|
|
|
+// If name!="" and url!="" then set the status type to streaming with the URL set.
|
|
// if otherwise, set status to active, and no game.
|
|
// if otherwise, set status to active, and no game.
|
|
-func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err error) {
|
|
|
|
- gameType := GameTypeGame
|
|
|
|
|
|
+func (s *Session) UpdateStreamingStatus(idle int, name string, url string) (err error) {
|
|
|
|
+ gameType := ActivityTypeGame
|
|
if url != "" {
|
|
if url != "" {
|
|
- gameType = GameTypeStreaming
|
|
|
|
|
|
+ gameType = ActivityTypeStreaming
|
|
}
|
|
}
|
|
- return s.UpdateStatusComplex(*newUpdateStatusData(idle, gameType, game, url))
|
|
|
|
|
|
+ return s.UpdateStatusComplex(*newUpdateStatusData(idle, gameType, name, url))
|
|
}
|
|
}
|
|
|
|
|
|
// UpdateListeningStatus is used to set the user to "Listening to..."
|
|
// UpdateListeningStatus is used to set the user to "Listening to..."
|
|
-// If game!="" then set to what user is listening to
|
|
|
|
-// Else, set user to active and no game.
|
|
|
|
-func (s *Session) UpdateListeningStatus(game string) (err error) {
|
|
|
|
- return s.UpdateStatusComplex(*newUpdateStatusData(0, GameTypeListening, game, ""))
|
|
|
|
|
|
+// If name!="" then set to what user is listening to
|
|
|
|
+// Else, set user to active and no activity.
|
|
|
|
+func (s *Session) UpdateListeningStatus(name string) (err error) {
|
|
|
|
+ return s.UpdateStatusComplex(*newUpdateStatusData(0, ActivityTypeListening, name, ""))
|
|
}
|
|
}
|
|
|
|
|
|
// UpdateStatusComplex allows for sending the raw status update data untouched by discordgo.
|
|
// UpdateStatusComplex allows for sending the raw status update data untouched by discordgo.
|