def self_post():
for i in sub_reddit:
reddit.subreddit(i).submit(post_title, url=post_body)
print("posted on " + i)
print(submission.permalink)
submission.reply('This is a test reply')
print(submission.permalink)
posting the thread works just fine, but i'm trying to get the post URL, then reply to that submission, how would i do that?
The submit
method returns the submission that has been created. So you can save it by doing
submission = reddit.subreddit(subreddit).submit(post_title, selftext=post_body)
You can also get the comment created via reply
by saving the result of calling that method:
comment = submission.reply('This is a test reply')
Then your function becomes:
def self_post(post_title, post_body):
for subreddit in sub_reddit:
submission = reddit.subreddit(subreddit).submit(post_title, url=post_body)
print("posted on " + subreddit)
print(submission.permalink)
reply = submission.reply('This is a test reply')
print(reply.permalink)