mirror of
https://github.com/Luzifer/discord-community.git
synced 2024-12-20 02:11:23 +00:00
[liveposting] Add some debug logging to post creation
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
60146d4fe1
commit
d7b74f4d6c
1 changed files with 9 additions and 0 deletions
|
@ -223,6 +223,11 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
|
|||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
|
||||
logger := log.WithFields(log.Fields{
|
||||
"user": username,
|
||||
"game": game,
|
||||
})
|
||||
|
||||
postText := strings.NewReplacer(
|
||||
"${displayname}", displayName,
|
||||
"${username}", username,
|
||||
|
@ -246,6 +251,7 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
|
|||
return errors.Wrap(err, "parsing message timestamp")
|
||||
}
|
||||
if msg.Content == postText && time.Since(mt) < ignoreTime {
|
||||
logger.Debug("Not creating live-post, it's already there")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -290,6 +296,8 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
|
|||
URL: strings.Join([]string{"https://www.twitch.tv", username}, "/"),
|
||||
}
|
||||
|
||||
logger.Debug("Creating live-post")
|
||||
|
||||
msg, err := m.discord.ChannelMessageSendComplex(channelID, &discordgo.MessageSend{
|
||||
Content: postText,
|
||||
Embed: msgEmbed,
|
||||
|
@ -300,6 +308,7 @@ func (m *modLivePosting) sendLivePost(username, displayName, title, game, previe
|
|||
|
||||
// @attr auto_publish optional bool "false" Automatically publish (crosspost) the message to followers of the channel
|
||||
if m.attrs.MustBool("auto_publish", ptrBoolFalse) {
|
||||
logger.Debug("Auto-Publishing live-post")
|
||||
if _, err = m.discord.ChannelMessageCrosspost(channelID, msg.ID); err != nil {
|
||||
return errors.Wrap(err, "publishing message")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue