Skip to content

Commit a06a0b7

Browse files
committed
Added better handling for private subreddits in the future
1 parent 89c9741 commit a06a0b7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

MountainProjectBot/RedditHelper.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,16 @@ public async Task Auth(string filePath)
5252
redditService = new Reddit(webAgent, true);
5353

5454
foreach (string subRedditName in subredditNamesAndCommentAmounts.Keys)
55-
Subreddits.Add(await redditService.GetSubredditAsync(subRedditName));
55+
{
56+
try
57+
{
58+
Subreddits.Add(await redditService.GetSubredditAsync(subRedditName));
59+
}
60+
catch (Exception ex)
61+
{
62+
Console.WriteLine($"Could not add subreddit {subRedditName}: {ex.Message}");
63+
}
64+
}
5665

5766
Console.WriteLine("Reddit authed successfully");
5867
}

0 commit comments

Comments
 (0)