Clean up status methods.
This commit is contained in:
parent
e8cd93cf15
commit
7f8369a45f
1 changed files with 31 additions and 40 deletions
71
wsapi.go
71
wsapi.go
|
@ -323,16 +323,8 @@ type updateStatusOp struct {
|
|||
Data UpdateStatusData `json:"d"`
|
||||
}
|
||||
|
||||
// UpdateStreamingStatus is used to update the user's streaming status.
|
||||
// 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 otherwise, set status to active, and no game.
|
||||
func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err error) {
|
||||
|
||||
s.log(LogInformational, "called")
|
||||
|
||||
usd := UpdateStatusData{
|
||||
func newUpdateStatusData(idle int, gameType GameType, game, url string) *UpdateStatusData {
|
||||
usd := &UpdateStatusData{
|
||||
Status: "online",
|
||||
}
|
||||
|
||||
|
@ -341,10 +333,6 @@ func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err
|
|||
}
|
||||
|
||||
if game != "" {
|
||||
gameType := GameTypeGame
|
||||
if url != "" {
|
||||
gameType = GameTypeStreaming
|
||||
}
|
||||
usd.Game = &Game{
|
||||
Name: game,
|
||||
Type: gameType,
|
||||
|
@ -352,7 +340,35 @@ func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err
|
|||
}
|
||||
}
|
||||
|
||||
return s.UpdateStatusComplex(usd)
|
||||
return usd
|
||||
}
|
||||
|
||||
// UpdateStatus is used to update the user's status.
|
||||
// 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, ""))
|
||||
}
|
||||
|
||||
// UpdateStreamingStatus is used to update the user's streaming status.
|
||||
// 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 otherwise, set status to active, and no game.
|
||||
func (s *Session) UpdateStreamingStatus(idle int, game string, url string) (err error) {
|
||||
gameType := GameTypeGame
|
||||
if url != "" {
|
||||
gameType = GameTypeStreaming
|
||||
}
|
||||
return s.UpdateStatusComplex(*newUpdateStatusData(idle, gameType, game, url))
|
||||
}
|
||||
|
||||
// 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, ""))
|
||||
}
|
||||
|
||||
// UpdateStatusComplex allows for sending the raw status update data untouched by discordgo.
|
||||
|
@ -371,31 +387,6 @@ func (s *Session) UpdateStatusComplex(usd UpdateStatusData) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// UpdateStatus is used to update the user's status.
|
||||
// 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.UpdateStreamingStatus(idle, game, "")
|
||||
}
|
||||
|
||||
// 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) {
|
||||
usd := UpdateStatusData{
|
||||
Status: "online",
|
||||
}
|
||||
if game != "" {
|
||||
usd.Game = &Game{
|
||||
Name: game,
|
||||
Type: GameTypeListening,
|
||||
URL: "",
|
||||
}
|
||||
}
|
||||
return s.UpdateStatusComplex(usd)
|
||||
}
|
||||
|
||||
type requestGuildMembersData struct {
|
||||
GuildID string `json:"guild_id"`
|
||||
Query string `json:"query"`
|
||||
|
|
Loading…
Reference in a new issue