Show message when subreddit invalid
This commit is contained in:
@@ -26,6 +26,11 @@ class Reddit(commands.Cog):
|
||||
client_secret=REDDIT_CLIENT_SECRET,
|
||||
user_agent=REDDIT_CLIENT_USERAGENT)
|
||||
|
||||
try:
|
||||
reddit.subreddits.search_by_name(sub, exact=True)
|
||||
except:
|
||||
await ctx.send(f"Subreddit {sub} not found!")
|
||||
|
||||
try:
|
||||
if sorting == "hot":
|
||||
posts = reddit.subreddit(sub).hot()
|
||||
@@ -45,10 +50,10 @@ class Reddit(commands.Cog):
|
||||
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!")
|
||||
else:
|
||||
text = f""
|
||||
text = ""
|
||||
if submission.over_18:
|
||||
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(submission.url)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user