async def is_demo(self) -> bool: """ Returns if the account is a demo account (unpaid). Returns: bool: Returns True if the account is a demo account (unpaid). """ connection = await self._create_connection( f'/users/profiles/minecraft/{self.profiles}?at={self.at}') if connection is None: return None if 'error' in connection: raise ApiException(f"{connection['errorMessage']}") if 'demo' in connection: return True return False
async def get_history(self, num: Optional[int] = None) -> dict: """ Gets the name history for the user. Returns: dict: Returns the name history for the given user at the given timestamp. """ connection = await self._create_connection( f'user/profile/{await self.uuid}/names') if connection is None: return None if 'error' in connection: raise ApiException(f"{connection['errorMessage']}") if num is None: return connection return connection[num]
async def get_uuids(self, *queries) -> list: """ Returns a list of uuids obtained using Mojang's API. Returns: list: The uuids obtained. """ payload = await self._send_payload(queries) uuids = [] for item in payload: try: if 'error' in payload: raise ApiException(f"{payload['errorMessage']}") uuids.append(item['id']) except KeyError: raise BadRequestException(payload['errorMessage']) return uuids
async def uuid(self) -> str: """ Gets the uuid for the user. Returns: str: Returns the uuid of the user. Raises: BadRequestError: If no user with these parameters can be found. """ connection = await self._create_connection( f'/users/profiles/minecraft/{self.profiles}?at={self.at}') try: if connection is None: return None if 'error' in connection: raise ApiException(f"{connection['errorMessage']}") return connection['id'] except KeyError: raise BadRequestException(connection['errorMessage'])
async def name(self) -> str: """ Gets the name for the user. Returns: str: Returns the name of the user. Raises: BadRequestError: If no user with these parameters can be found. """ connection = await self._create_connection( f'user/profile/{self.profiles}/names') try: if connection is None: return None if 'error' in connection: raise ApiException(f"{connection['errorMessage']}") return connection[len(connection) - 1]['name'] except KeyError: raise BadRequestException(connection['errorMessage'])