Enforce limits on subreddits
This commit is contained in:
parent
86db405b1a
commit
4601789da0
2 changed files with 17 additions and 5 deletions
|
@ -69,6 +69,18 @@ class RedditCog(Scale):
|
||||||
await ctx.send("Subreddit may be private, quarantined, or nonexistent.", ephemeral=True)
|
await ctx.send("Subreddit may be private, quarantined, or nonexistent.", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
count = len([i async for i in SubredditFollow.find(q(guild=ctx.guild.id))])
|
||||||
|
if len(count) >= 12:
|
||||||
|
await ctx.send("Cannot follow more than 12 Subreddits", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
exists = await SubredditFollow.find_one(
|
||||||
|
q(display_name=subreddit.display_name, guild=ctx.guild.id)
|
||||||
|
)
|
||||||
|
if exists:
|
||||||
|
await ctx.send("Subreddit already being followed in this guild", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
sr = await Subreddit.find_one(q(display_name=subreddit.display_name))
|
sr = await Subreddit.find_one(q(display_name=subreddit.display_name))
|
||||||
if not sr:
|
if not sr:
|
||||||
sr = Subreddit(display_name=subreddit.display_name, over18=subreddit.over18)
|
sr = Subreddit(display_name=subreddit.display_name, over18=subreddit.over18)
|
||||||
|
|
|
@ -80,16 +80,16 @@ class TwitterCog(Scale):
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
count = len([i async for i in TwitterFollow.find(q(guild=ctx.guild.id))])
|
|
||||||
if count >= 12:
|
|
||||||
await ctx.send("Cannot follow more than 12 Twitter accounts", ephemeral=True)
|
|
||||||
return
|
|
||||||
|
|
||||||
exists = await TwitterFollow.find_one(q(twitter_id=account.id, guild=ctx.guild.id))
|
exists = await TwitterFollow.find_one(q(twitter_id=account.id, guild=ctx.guild.id))
|
||||||
if exists:
|
if exists:
|
||||||
await ctx.send("Twitter account already being followed in this guild", ephemeral=True)
|
await ctx.send("Twitter account already being followed in this guild", ephemeral=True)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
count = len([i async for i in TwitterFollow.find(q(guild=ctx.guild.id))])
|
||||||
|
if count >= 12:
|
||||||
|
await ctx.send("Cannot follow more than 12 Twitter accounts", ephemeral=True)
|
||||||
|
return
|
||||||
|
|
||||||
ta = await TwitterAccount.find_one(q(twitter_id=account.id))
|
ta = await TwitterAccount.find_one(q(twitter_id=account.id))
|
||||||
if not ta:
|
if not ta:
|
||||||
ta = TwitterAccount(
|
ta = TwitterAccount(
|
||||||
|
|
Loading…
Add table
Reference in a new issue