Fix votes only being showed after a new vote and chris fixed everything

This commit is contained in:
Sebastian Cabrera 2023-08-30 19:43:42 -04:00
parent 194d13d039
commit 6b1880cff7
2 changed files with 10 additions and 10 deletions

View file

@ -1,6 +1,6 @@
package main package main
var version = "v0.02" var version = "v0.03"
func main() { func main() {
initGitHubClient(version) initGitHubClient(version)

View file

@ -177,10 +177,11 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
} }
return return
} else { }
commentText := "Votes: (#{reactionCount})/(#{reactionCountGoal})"
commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(len(approvals)), 1) if approvals[eventSender] > 1 {
commentText = strings.Replace(commentText, "(#{reactionCountGoal})", strconv.Itoa(reactionCountGoal), 1) commentText := "@(#{commentAuthor}) your vote has already been counted :x:"
commentText = strings.Replace(commentText, "(#{commentAuthor})", eventSender, 1)
// Respond with a comment // Respond with a comment
comment := &github.IssueComment{ comment := &github.IssueComment{
@ -191,11 +192,10 @@ func processIssueCommentEvent(event *github.IssueCommentEvent) {
if err != nil { if err != nil {
log.Println("Error creating comment:", err) log.Println("Error creating comment:", err)
} }
} } else {
commentText := "@(#{commentAuthor}) voted! :tada:\n" + "Votes: (#{reactionCount})/(#{reactionCountGoal})"
if approvals[eventSender] > 1 { commentText = strings.Replace(commentText, "(#{reactionCount})", strconv.Itoa(len(approvals)), 1)
commentText := "@(#{commentAuthor}) your vote has already been counted :x:" commentText = strings.Replace(commentText, "(#{reactionCountGoal})", strconv.Itoa(reactionCountGoal), 1)
commentText = strings.Replace(commentText, "(#{commentAuthor})", eventSender, 1)
// Respond with a comment // Respond with a comment
comment := &github.IssueComment{ comment := &github.IssueComment{