Fix panic when a ticket is closed and the log contains no messages
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2023-12-15 06:57:55 -08:00
parent 4f7b22505b
commit 8452a2e8e9
1 changed files with 4 additions and 0 deletions

View File

@ -248,6 +248,10 @@ func getChannelMessageLog(s *discordgo.Session, channelID string) (*bytes.Buffer
// writeMsgs writes a slice of messages to w.
func writeMsgs(msgs []*discordgo.Message, w io.Writer) error {
if len(msgs) == 0 {
return nil
}
for i := len(msgs); i >= 0; i-- {
_, err := io.WriteString(w, fmt.Sprintf("%s - %s\n", msgs[i].Author.Username, msgs[i].Content))
if err != nil {