From bd46a37beae26a8dd09c29bfa0911262c3f39270 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 26 Aug 2021 00:36:59 +0200 Subject: [PATCH] Add logging for successful role change Signed-off-by: Knut Ahlers --- mod_liveRole.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mod_liveRole.go b/mod_liveRole.go index b60b85a..cee3a35 100644 --- a/mod_liveRole.go +++ b/mod_liveRole.go @@ -100,6 +100,7 @@ func (m modLiveRole) handlePresenceUpdate(d *discordgo.Session, p *discordgo.Pre if err := exitFunc(p.GuildID, p.User.ID, member.Roles); err != nil { logger.WithError(err).Error("Unable to update live-streamer-role") } + logger.Info("Updated live-streamer-role") } }() @@ -115,6 +116,7 @@ func (m modLiveRole) handlePresenceUpdate(d *discordgo.Session, p *discordgo.Pre if activity == nil { // No streaming activity: Remove role exitFunc = m.removeLiveStreamerRole + logger = logger.WithField("action", "remove") return } @@ -122,12 +124,14 @@ func (m modLiveRole) handlePresenceUpdate(d *discordgo.Session, p *discordgo.Pre if err != nil { logger.WithError(err).WithField("url", activity.URL).Warning("Unable to parse activity URL") exitFunc = m.removeLiveStreamerRole + logger = logger.WithField("action", "remove") return } if u.Host != "www.twitch.tv" { logger.WithError(err).WithField("url", activity.URL).Warning("Activity is not on Twitch") exitFunc = m.removeLiveStreamerRole + logger = logger.WithField("action", "remove") return } @@ -143,11 +147,13 @@ func (m modLiveRole) handlePresenceUpdate(d *discordgo.Session, p *discordgo.Pre if err != nil { logger.WithError(err).WithField("user", strings.TrimLeft(u.Path, "/")).Warning("Unable to fetch streams for user") exitFunc = m.removeLiveStreamerRole + logger = logger.WithField("action", "remove") return } if len(streams.Data) > 0 { exitFunc = m.addLiveStreamerRole + logger = logger.WithField("action", "add") } }