Skip to content

Commit

Permalink
Merge pull request #162 from MiscGuild/ratelimit-fix
Browse files Browse the repository at this point in the history
Ratelimit fix
  • Loading branch information
Amxgh authored Jan 16, 2024
2 parents 4754989 + 84f81e4 commit c5b5f19
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utils/request_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ async def get_hyapi_key():
async def get_json_response(url: str):
async with aiohttp.ClientSession() as session:
async with session.get(url) as resp:
if resp.status != 200:
return None
resp = await resp.json(content_type=None)
await session.close()

Expand Down Expand Up @@ -106,6 +108,9 @@ async def get_guild_by_name(name):
api_key = await get_hyapi_key()
resp = await get_json_response(f"https://api.hypixel.net/guild?key={api_key}&name={name}")

if not resp:
return None

# Player is not in a guild
if "guild" not in resp or not resp["guild"]:
return None
Expand Down

0 comments on commit c5b5f19

Please sign in to comment.