Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError: local variable 'response' referenced before assignment #20

Open
ps2cho opened this issue Jan 27, 2020 · 3 comments
Open
Assignees
Labels

Comments

@ps2cho
Copy link

ps2cho commented Jan 27, 2020

Ignoring exception in on_message
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/discord/client.py", line 270, in _run_event
    await coro(*args, **kwargs)
  File "/home/pi/Desktop/bot/cogs/Chatting.py", line 515, in on_message
    hypixel.setKeys(API_KEYS)
  File "/usr/local/lib/python3.6/site-packages/hypixel.py", line 128, in setKeys
    response = getJSON('key', key=api_key)
  File "/usr/local/lib/python3.6/site-packages/hypixel.py", line 67, in getJSON
    if response['success'] is False:
UnboundLocalError: local variable 'response' referenced before assignment

        if message.content.startswith("빠봇 하픽전적"):

            a = message.content[8:].lstrip()
            if a =="":
                embed=discord.Embed(title="⚠ 주의", description="검색어가 없습니다.",color=0xd8ef56)
                await message.channel.send(embed=embed)
            else:
                API_KEYS = ['********']
                hypixel.setKeys(API_KEYS) 

                Player = hypixel.Player(a) 
                PlayerName = Player.getName() 
                PlayerLevel = Player.getLevel()
                PlayerRank = Player.getRank()
                Playerinfo = Player.getPlayerInfo()

                embed = discord.Embed(colour = 0xFDFFE9, title = '하이픽셀 전적')

                embed.add_field(name='닉네임', value=Playername, inline=False)
                embed.add_field(name='레벨', value=PlayerLebel, inline=False)

                embed.add_field(name='랭크', value=PlayerRank['rank'], inline=False)                  
                await message.channel.send(embed=embed)

Why does this happen??

@Snuggle
Copy link
Owner

Snuggle commented May 24, 2021

Hello, @ps2cho & @beardotpy! This hopefully is fixed by 6903c76. Could you please see if v0.8.0 of hypixel.py fixes this issue for you? If you use Python's PIP, you can run something like: pip install hypixel --upgrade to upgrade the package.

@Snuggle Snuggle self-assigned this May 24, 2021
@4444dogs
Copy link

I am having this issue too, even after the fix.

1 similar comment
@Gingmzmzx
Copy link

I am having this issue too, even after the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants