diff --git a/README.md b/README.md index e36f7fe..9a4b90e 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ If a moderator accepts the request, a new ticket will be created in which mods c ### Tickets -owobot can create tickets, which are private channels that allow users to talk directly to your server's moderators. When a ticket is closed, owobot compiles a log containing all the messages in the ticket and sends it to the event log ticket channel. +owobot can create tickets, which are private channels that allow users to talk directly to your server's moderators. When a ticket is closed, owobot compiles a log containing up to 100 messages from the ticket and sends it to the event log ticket channel. A user can only have one open ticket at a time. diff --git a/internal/systems/tickets/tickets.go b/internal/systems/tickets/tickets.go index c03a212..c3a5561 100644 --- a/internal/systems/tickets/tickets.go +++ b/internal/systems/tickets/tickets.go @@ -243,26 +243,13 @@ func getChannelMessageLog(s *discordgo.Session, channelID string) (*bytes.Buffer return nil, err } - msgAmt := len(msgs) - for msgAmt == 100 { - innerMsgs, err := s.ChannelMessages(channelID, 100, "", msgs[99].ID, "") - if err != nil { - return nil, err - } - err = writeMsgs(innerMsgs, out) - if err != nil { - return nil, err - } - msgAmt = len(innerMsgs) - } - return out, nil } // writeMsgs writes a slice of messages to w. func writeMsgs(msgs []*discordgo.Message, w io.Writer) error { - for _, msg := range msgs { - _, err := io.WriteString(w, fmt.Sprintf("%s - %s\n", msg.Author.Username, msg.Content)) + 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 { return err }