Kanin / PyPixel

A Python Wrapper for The Hypixel API
MIT License
10 stars 2 forks source link

TypeError: unsupported operand type(s) for +=: 'Request' and 'str' #12

Closed Tmpod closed 4 years ago

Tmpod commented 6 years ago

When I run this code

import pypixel
import json
api = pypixel.HypixelAPI("xxxxxxxxxxxxxxx")
p = json.dumps(api.userByName("destruc7i0n"), indent=4, separators=(',', ': '))
print(p)

I get this error

File "xxxxxx\pypixel.py", line 124, in urlopen
    url += expandUrlData(params)
TypeError: unsupported operand type(s) for +=: 'Request' and 'str'

I'm on Python 3.4.3.

destruc7i0n commented 6 years ago

Sorry for the late reply! It seems that the API that we were using at the time ( https://github.com/destruc7i0n/PyPixel/blob/master/pypixel.py#L124 ) has been removed. Right now I don't know of any viable replacement, other than just checking getUUID().

Tmpod commented 6 years ago

Oh ok... I also did some research and couldn't find anything. Well when you find something please notify me. Thanks

destruc7i0n commented 6 years ago

As I said, it probably won’t be able to get replaced. The only way would be to remove all call to it.

HiddenKitten commented 6 years ago

would replacing the api you use with this not work? http://wiki.vg/Mojang_API#Username_-.3E_UUID_at_time

if the account doesn't exist at all, there's a 204 error, and if it does, but it's a demo account (legacy...) then it will have the "demo" key.

edit: actually just looked and you already do call this API elsewhere, would it not be a good idea to only handle this with the other API call, perhaps returning a tuple?

HiddenKitten commented 6 years ago

@Tmpod if this is still relevant to you at all, you could try to use the code from my pull request, #13, was looking into using this for something and if I had to run calls against a list of users, then throwing an error like that would be best, so I can catch and continue with the rest, for me at least. our use cases might be different, but this does fix the snippet you sent. (use caution, it's fairly untested with anything else right now)