I'm trying to make a bot that increments a number every time someone mentions a string. So far I can only get it to increment once and every other reply stays at the same number. It is declared at 2017, but will only reply with 2018 when it finds a string. I know its something small I'm missing but I cant figure it out.
for comment in r.subreddit('test').comments(limit = 500):
mentions = 2017
if "string" in comment.body and comment.id not in comments_replied_to and comment.author != r.user.me():
mentions +=1
print ("string found!") and comment.id
comment.reply(" delayed until year" + str(mentions))
print("replied to comment")
You're declaring mentions
inside the body of the loop, meaning it will be set to 2017
on every iteration.
Also, print ("string found!") and comment.id
should probably be print("string found!", comment.id)
.