Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Thread method isn't returning the fully parsed comment tree. #90

Open
krishamoud opened this issue Nov 25, 2021 · 1 comment
Open

Comments

@krishamoud
Copy link

krishamoud commented Nov 25, 2021

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.

@dnapier
Copy link

dnapier commented Dec 27, 2021

Your loop needs expanding

for _, comment := range thread.Replies {
	for _, v := range comment.Replies {
		fmt.Println(v)
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants