graw
graw copied to clipboard
The Thread method isn't returning the fully parsed comment tree.
Maybe I'm doing something wrong but after going through the documentation and trying to figure out what's happening I'm not sure what I'm doing wrong.
The simplest reproduction of it is this.
package main
import (
"fmt"
"github.com/turnage/graw/reddit"
)
func main() {
if bot, err := reddit.NewBotFromAgentFile("some-app.agent", 0); err != nil {
fmt.Println("Failed to create bot handle: ", err)
} else {
thread, err := bot.Thread("/r/golang/comments/bv0azt/using_graw_a_reddit_api_wrapper_for_go_like_praw/")
if err != nil {
fmt.Println(err)
}
for _, comment := range thread.Replies {
fmt.Println(comment.Body)
}
}
}
Which outputs
⇒ go run main.go
Did this get resolved? I'm having the same problem.
And it should have three comments unless I'm misunderstanding something.
link to the reddit thread in question
Thanks in advance! I feel like I'm missing something silly.
Your loop needs expanding
for _, comment := range thread.Replies {
for _, v := range comment.Replies {
fmt.Println(v)
}
}