Skip to content

Commit

Permalink
defered timed message deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
1nv8rzim committed Sep 14, 2023
1 parent 4f006b9 commit 322f5c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
16 changes: 9 additions & 7 deletions commands/slash/kudos.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,16 @@ func Kudos() *structs.SlashCommand {
logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err})
}

wg.Wait()
defer func() {
err = s.ChannelMessageDelete(KudosApprovalChannelID, approvalMessage.ID)
if err != nil {
logging.Error(s, "Error deleting channel message", i.Member.User, span, logrus.Fields{"error": err})
}
delete(*ComponentHandlers, approve_slug)
delete(*ComponentHandlers, deny_slug)
}()

err = s.ChannelMessageDelete(KudosApprovalChannelID, approvalMessage.ID)
if err != nil {
logging.Error(s, "Error deleting channel message", i.Member.User, span, logrus.Fields{"error": err})
}
delete(*ComponentHandlers, approve_slug)
delete(*ComponentHandlers, deny_slug)
wg.Wait()
},
}
}
12 changes: 7 additions & 5 deletions commands/slash/signin.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,14 @@ func Signin() *structs.SlashCommand {
logging.Error(s, err.Error(), i.Member.User, span, logrus.Fields{"error": err})
}

time.Sleep(time.Duration(delay) * time.Hour)
defer func() {
err = s.ChannelMessageDelete(i.ChannelID, message.ID)
if err != nil {
logging.Error(s, "Error encounted while deleting message\n\n"+err.Error(), i.Member.User, span, logrus.Fields{"error": err})
}
}()

err = s.ChannelMessageDelete(i.ChannelID, message.ID)
if err != nil {
logging.Error(s, "Error encounted while deleting message\n\n"+err.Error(), i.Member.User, span, logrus.Fields{"error": err})
}
time.Sleep(time.Duration(delay) * time.Hour)
},
}
}
Expand Down

0 comments on commit 322f5c1

Please sign in to comment.