-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodules.py
99 lines (68 loc) · 3.07 KB
/
modules.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#importing directories
import discord
from discord.ext import commands
from replit import db
import asyncpraw
import os
import asyncio
#reddit login credentials
reddit = asyncpraw.Reddit(client_id=os.getenv("clientid"),
client_secret=os.getenv("secret"),
username="",
password=os.getenv("password"),
user_agent=os.getenv("agent"))
intents = discord.Intents.all()
client = commands.Bot(command_prefix='-', intents=intents)
#modules
async def advertisehot(ctx, subreddit, lim, title, content):
await ctx.send("_ _")
await ctx.send(f"[*Inviting from **r/{subreddit}***]")
await ctx.send("_ _")
sub = await reddit.subreddit(subreddit)
topsub = sub.hot(limit = lim)
async for submission in topsub:
print(f"starting {subreddit}")
try:
if submission.author.name.lower() in db["dmd"]:
print(submission.author.name,
": found in the dm log, going to next user")
continue
else:
print(submission.author.name, ": didnt find in the dm log")
db["dmd"] = db["dmd"] + "," + submission.author.name.lower()
print("written in the dm log")
tuser = await reddit.redditor(submission.author.name)
await tuser.message(title,content)
await ctx.send(
f"{submission.author.name} has been dmd an invite")
await asyncio.sleep(45)
except:
print(f"{submission.author.name} probably has dms off, not added to dm log")
await ctx.send(f"Couldnt dm {submission.author.name}, they probably have dms off")
continue
async def advertisenew(ctx, subreddit, lim, title, content):
await ctx.send("_ _")
await ctx.send(f"[*Inviting from **r/{subreddit}***]")
await ctx.send("_ _")
sub = await reddit.subreddit(subreddit)
bottomsub = sub.new(limit = lim)
async for submission in bottomsub:
print(f"starting {subreddit}")
try:
if submission.author.name.lower() in db["dmd"]:
print(submission.author.name,
": found in the dm log, going to next user")
continue
else:
print(submission.author.name, ": didnt find in the dm log")
db["dmd"] = db["dmd"] + "," + submission.author.name.lower()
print("written in the dm log")
tuser = await reddit.redditor(submission.author.name)
await tuser.message(title, content)
await ctx.send(
f"{submission.author.name} has been dmd an invite")
await asyncio.sleep(45)
except:
print(f"{submission.author.name} probably has dms off, not added to dm log")
await ctx.send(f"Couldnt dm {submission.author.name}, they probably have dms off")
continue