0

I can't find how to get them, so i hope someone will help

subreddit = await reddit.subreddit(next_subred)
submission = subreddit.new(limit=1)
item = await submission.__anext__()
image = item.url

work only if image one

1 Answers1

0

Sorry if I misunderstood what you wanted to say in the title, but I guess you are facing issues getting posts from reddit if I am not mistaken?

Of course it works only for one image!So, first of all you need to iterate thought all the posts so you need a for loop, the limit is how many posts you want your program to look for, and image_list is a list where we add all the urls. So the code will be something like this:

async for submission in subreddit(limit=50):
                    #Checking if the post is not pinned
                    if not submission.stickied:
                        url = str(submission.url)
                        image_list.append(url)
                        continue
                await message.channel.send(image)
                await reddit.close()

You can skip if not submission.stickied if you also want to get the pinned posts!

I hoped this helped!