Fix ticket log format and limit to 100 messages
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
2c84e6b79c
commit
e6d17e796f
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue