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

View File

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