From b0fe81808b32650e7dd6a7a8a86d5fc36c27c2fe Mon Sep 17 00:00:00 2001 From: Den4200 Date: Wed, 30 Sep 2020 23:34:45 -0400 Subject: Check the GitHub user exists before searching for their PRs. Ensures an error does not occur when a GitHub user does not exist. --- bot/exts/halloween/hacktoberstats.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bot/exts/halloween/hacktoberstats.py b/bot/exts/halloween/hacktoberstats.py index 3347dd8f..a2261caf 100644 --- a/bot/exts/halloween/hacktoberstats.py +++ b/bot/exts/halloween/hacktoberstats.py @@ -247,6 +247,11 @@ class HacktoberStats(commands.Cog): ) async with aiohttp.ClientSession() as session: + async with session.get(f"https://api.github.com/users/{github_username}", headers=REQUEST_HEADERS) as resp: + if resp.status == 404: + logging.debug(f"No GitHub user found named '{github_username}'") + return + async with session.get(query_url, headers=REQUEST_HEADERS) as resp: jsonresp = await resp.json() -- cgit v1.2.3