Show message when subreddit invalid
This commit is contained in:
@@ -26,6 +26,11 @@ class Reddit(commands.Cog):
|
|||||||
client_secret=REDDIT_CLIENT_SECRET,
|
client_secret=REDDIT_CLIENT_SECRET,
|
||||||
user_agent=REDDIT_CLIENT_USERAGENT)
|
user_agent=REDDIT_CLIENT_USERAGENT)
|
||||||
|
|
||||||
|
try:
|
||||||
|
reddit.subreddits.search_by_name(sub, exact=True)
|
||||||
|
except:
|
||||||
|
await ctx.send(f"Subreddit {sub} not found!")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if sorting == "hot":
|
if sorting == "hot":
|
||||||
posts = reddit.subreddit(sub).hot()
|
posts = reddit.subreddit(sub).hot()
|
||||||
@@ -45,10 +50,10 @@ class Reddit(commands.Cog):
|
|||||||
if submission.over_18 and not ctx.channel.is_nsfw():
|
if submission.over_18 and not ctx.channel.is_nsfw():
|
||||||
await ctx.send("The post is marked as NSFW, but your text channel isn't!")
|
await ctx.send("The post is marked as NSFW, but your text channel isn't!")
|
||||||
else:
|
else:
|
||||||
text = f""
|
text = ""
|
||||||
if submission.over_18:
|
if submission.over_18:
|
||||||
text += "❗ NSFW ❗"
|
text += "❗ NSFW ❗"
|
||||||
text += "'{submission.title}' by {submission.author.name} - 🔼 {submission.score}"
|
text += f"'{submission.title}' by {submission.author.name} - 🔼 {submission.score}"
|
||||||
await ctx.send(text)
|
await ctx.send(text)
|
||||||
await ctx.send(submission.url)
|
await ctx.send(submission.url)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user