I am trying to create a listener
for meme. The bot will respond to the message when it has "meme"
in it. It has to send a meme. I am using Praw for that purpose.
This is the code I have written:
@nd.listen()
async def on_message(message):
if message.author == nd.user:
return
def findCoindences(w):
return re.compile(r'\b({0})\b'.format(w)).search
content = message.content
reaction = "👍"
subreddit = reddit.subreddit("memes")
for submission in subreddit.random():
submission_link = submission.url
if findCoindences('meme')(content.lower()):
await message.reply(submission_link)
await message.add_reaction(f"<{reaction}>")
Note: I have defined reddit
already above some lines. That is not the cause I guess.
The problem:
Whenever I send meme
in the chat it sends the same meme every time. I want it to be different but don't know where I am having this issue.
random_submission = reddit.subreddit('memes').random()
. I am not sure what iterating oversubreddit.random()
is even doing.Submission is not iterable
.