Skip to content

Instantly share code, notes, and snippets.

@rajtilakjee
Created June 26, 2023 05:24
Show Gist options
  • Save rajtilakjee/ede7f15b33add40442da7fe69388d26f to your computer and use it in GitHub Desktop.
Save rajtilakjee/ede7f15b33add40442da7fe69388d26f to your computer and use it in GitHub Desktop.
Reddit Modmail Bot
import praw
import discord
import os
from dotenv import load_dotenv
load_dotenv()
reddit = praw.Reddit(
client_id=os.getenv('API_CLIENT'),
client_secret=os.getenv('API_SECRET'),
password=os.getenv('REDDIT_PASSWORD'),
user_agent="Reddit Modmail Bot",
username=os.getenv('REDDIT_USERNAME'),
check_for_async=False
)
target_sub = "rajtilakjee"
subreddit = reddit.subreddit(target_sub)
webhook = discord.Webhook.from_url(os.getenv('DISCORD_URL'), adapter=discord.RequestsWebhookAdapter())
for modmail_conversation in subreddit.mod.stream.modmail_conversations(state='new'):
author=str(modmail_conversation.authors[0])
webhook.send("New Modmail from " + author)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment