diff options
author | 2020-09-30 23:34:45 -0400 | |
---|---|---|
committer | 2020-09-30 23:34:45 -0400 | |
commit | b0fe81808b32650e7dd6a7a8a86d5fc36c27c2fe (patch) | |
tree | 83fca9817c6875f9fd56024f3c38e4764cc7d497 /bot | |
parent | Authenticate GitHub API requests for Hacktoberfest stats. (diff) |
Check the GitHub user exists before searching for their PRs.
Ensures an error does not occur when a GitHub user does not exist.
Diffstat (limited to 'bot')
-rw-r--r-- | bot/exts/halloween/hacktoberstats.py | 5 |
1 files changed, 5 insertions, 0 deletions
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() |