Browse Source

Add a listening status method (#508)

* Bump to v0.17.0

* Add members from GuildMembersChunk to state (#454)

* Revert "Add members from GuildMembersChunk to state (#454)" (#455)

This reverts commit e4487b30d4d846b1fdc08fd3982bd5b9965a8cc9.

* travis: update go versions

* Allowed setting the game to null.

* Allowed for setting status to listening.

* Changed variable names for better consistency

* Reverted updateStatus to maintain API compatibility, instead added now
UpdateListeningStatus method which directly calls UpdateStatusComplex.

* Fix version to 0.18.0-alpha

* Make the new UpdateListeningStatus read a bit better.

* Updated setting game to nil for better compatibility.

* Remove the explicit nil check, as no longer seems to be needed.

* Fix comment styling.

* Remove idle as unused.
Daniel Thorpe 7 years ago
parent
commit
e8cd93cf15
2 changed files with 20 additions and 3 deletions
  1. 3 3
      .travis.yml
  2. 17 0
      wsapi.go

+ 3 - 3
.travis.yml

@@ -1,8 +1,8 @@
 language: go
 go:
-    - 1.7
-    - 1.8
-    - 1.9
+    - 1.7.x
+    - 1.8.x
+    - 1.9.x
 install:
     - go get github.com/bwmarrin/discordgo
     - go get -v .

+ 17 - 0
wsapi.go

@@ -379,6 +379,23 @@ 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"`