'Why is my discord bot posting old memes? | Discord.py
I'm making a discord meme bot and its working but I have a small problem with it. It keeps sending the same set of old memes for some reason. How do I fix that?
def updateMemes(subreddit = "memes"):
global name
global url
subreddit = reddit.subreddit("memes")
allSubs = []
top = subreddit.top(limit=100)
for submission in top:
allSubs.append(submission)
randomSub = random.choice(allSubs)
name = randomSub.title
url = randomSub.url
Solution 1:[1]
Because you're explicitly requesting the top 100 posts of all time, which rarely change.
top = subreddit.top(limit=100)
As you can see in the PRAW docs, the default value for time_filter is "all". If you want to get the top posts of today/this week/... instead, which will vary a lot more, then pass an argument for the time_filter parameter.
The accepted values, including examples, are in the docs page I linked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | stijndcl |
