2
0
mirror of https://github.com/Nick80835/microbot synced 2025-08-31 14:38:04 +00:00

make redt error less on empty subs

This commit is contained in:
Nick80835
2020-11-28 10:05:30 -05:00
parent f8b28157be
commit eb71d6b688

View File

@@ -67,12 +67,16 @@ async def titlefetcher(event, sub):
try: try:
post = await subreddit.random() or await titlefetcherfallback(subreddit) post = await subreddit.random() or await titlefetcherfallback(subreddit)
post.title
except redex.Forbidden: except redex.Forbidden:
await event.reply(f"**r/{sub}** is private!") await event.reply(f"**r/{sub}** is private!")
return return
except (redex.NotFound, KeyError): except (redex.NotFound, KeyError):
await event.reply(f"**r/{sub}** doesn't exist!") await event.reply(f"**r/{sub}** doesn't exist!")
return return
except AttributeError:
await event.reply(f"Failed to find any valid content on **r/{sub}**!")
return
await event.reply(post.title) await event.reply(post.title)