Skip to content

Commit

Permalink
Merge pull request #17 from kehiy/main
Browse files Browse the repository at this point in the history
chore: update time format
  • Loading branch information
kehiy authored Nov 22, 2023
2 parents aaae3a0 + e73584d commit eb69305
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,19 @@ func (b *Bot) messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
}

if strings.ToLower(m.Content) == "health" {
currentTime := time.Now().Unix()
currentTime := time.Now()
lastBlockTime := b.cm.GetLastBlockTime()
lastBlockTimeFormatted := time.Unix(int64(lastBlockTime), 0)

if (uint32(currentTime) - lastBlockTime) > 15 {
if (uint32(currentTime.Unix()) - lastBlockTime) > 15 {
msg := p.Sprintf("Network is unhealthy\nlast block time: %v\ncurrent time: %v\nDifference is more than 15 seconds.",
lastBlockTime, currentTime)
lastBlockTimeFormatted.Format("02/01/2006, 15:04:05"), currentTime.Format("02/01/2006, 15:04:05"))
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}

msg := p.Sprintf("Network is **healthy**\nlast block time: %v\ncurrent time: %v\nDifference is less than 15 seconds.",
lastBlockTime, currentTime)
lastBlockTimeFormatted.Format("02/01/2006, 15:04:05"), currentTime.Format("02/01/2006, 15:04:05"))
_, _ = s.ChannelMessageSendReply(m.ChannelID, msg, m.Reference())
return
}
Expand Down

0 comments on commit eb69305

Please sign in to comment.