somewhat fix history, fix multiline replies

This commit is contained in:
Cynthia Foxwell 2023-08-18 00:06:58 -06:00
parent 41d3a6608f
commit 1e45d360b4
2 changed files with 13 additions and 5 deletions

View File

@ -2,7 +2,6 @@ package commands
import (
"fmt"
"math"
"strconv"
"strings"
@ -20,7 +19,7 @@ func GetHistory(limit int, channel string) {
return
}
messages, err := client.Messages(discord.ChannelID(parsedChannelId), 50)
messages, err := client.Messages(discord.ChannelID(parsedChannelId), 100)
if err != nil {
fmt.Print("<failed to get messages: ", err.Error(), ">\n\r")
return
@ -30,6 +29,8 @@ func GetHistory(limit int, channel string) {
messages[i], messages[j] = messages[j], messages[i]
}
state.SetInPrompt(true)
fmt.Print("--Beginning-Review", strings.Repeat("-", 62), "\n\r")
lines := make([]string, 0)
@ -41,12 +42,17 @@ func GetHistory(limit int, channel string) {
}
length := len(lines)
startIndex := int(math.Max(float64(0), float64(length - limit)))
for _, line := range lines[startIndex:] {
fmt.Print(line)
startIndex := length - limit
if startIndex < 0 {
startIndex = 0
}
for i := startIndex; i < length; i++ {
fmt.Print(lines[i])
}
fmt.Print("--Review-Complete", strings.Repeat("-", 63), "\n\r")
state.SetInPrompt(false)
}
func HistoryCommand() {

View File

@ -495,6 +495,8 @@ func ProcessMessage(msg discord.Message, options MessageOptions) []string {
options.Stickers = msg.Stickers
if i == 0 {
options.Reply = msg.ReferencedMessage
} else {
options.Reply = nil
}
options.Timestamp = time.Time(msg.Timestamp)
options.IsMention = isPing