Skip to content

Commit

Permalink
feat: added check_username function
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucino772 committed Mar 2, 2022
1 parent ae4c833 commit bdc952d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mojang/api/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ def check_product_voucher(access_token: str, voucher: str) -> bool:
return code == 200


def check_username(access_token: str, username: str) -> bool:
headers = helpers.get_headers(bearer=access_token)
response = requests.get(
urls.api_session_check_username(username), headers=headers
)
code, data = helpers.err_check(
response, (401, Unauthorized), (429, RuntimeError("Limited Endpoint"))
)

return data["status"] == "AVAILABLE"


def get_user_name_change(access_token: str) -> NameChange:
"""Return if user can change name and when it was created
Expand Down

0 comments on commit bdc952d

Please sign in to comment.