From e8cd93cf1502cbbe43ca3158ae7e8c45a9f2f2e8 Mon Sep 17 00:00:00 2001 From: Daniel Thorpe Date: Fri, 9 Feb 2018 04:50:07 +0000 Subject: [PATCH] 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. --- .travis.yml | 6 +++--- wsapi.go | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c181dda..fe626fc 100644 --- a/.travis.yml +++ b/.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 . diff --git a/wsapi.go b/wsapi.go index 3b18e65..f9d6029 100644 --- a/wsapi.go +++ b/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"`