0

i want to know if i can do response["rap"] == "null" then response["rap"] == "account is private"

im new to python / json reason for bad sytax an example of the api with response null is https://i.stack.imgur.com/IWXys.png

i included full code so you can test it out and play about with the code to see if you can get it to work

thanks for reading this

async def on_me

    global rap
    global response1234
    response1234 = requests.get(f'http://api.chloe.to/rbx?method=username&user={id}').json()

    rap = response["rap"]
    await asyncio.sleep(60)

    if rap == response["null"]:
        rap = "Private Account"
@bot.command()
async def account(ctx, id):
  response2 = response1234["id"] 
  id2r = discord.Embed()
  id2r.set_author(name='Status : Online', icon_url='https://cdn2.iconfinder.com/data/icons/greenline/512/check-512.png')
  id2r.set_thumbnail (url=response1234["avatar"])
  id2r.add_field(name='***Username ***', value=response1234["username"],inline = False)
  id2r.add_field(name='***RAP ***', value=f"{rap}",inline = False)
  id2r.add_field(name='***Rolimons Link***', value=f"https://www.rolimons.com/player/{response2}",inline = False)
  id2r.timestamp = datetime.now()
  await ctx.send(embed=id2r)
@account.error
async def kick_error(ctx, error):
  if isinstance(error, commands.UserInputError):
    support = discord.Embed()
    support.set_author(name='Status : Online', icon_url='https://cdn2.iconfinder.com/data/icons/greenline/512/check-512.png')
    support.set_thumbnail (url='https://i.gifer.com/VG4s.gif')
    support.add_field(
      name='***Error***', value='Did Not Provide Roblox Username', inline=False)
    support.timestamp = datetime.now()
    await ctx.send(embed=support)```


  
Pxndaaa
  • 13
  • 4
  • Yes, of course you can assign a variable to whatever value you want. – John Gordon Dec 26 '20 at 18:19
  • in the sample response you attached, `null` is not a string. You need to make a check using `None`. For example like this: `response["rap"] == None and response["rap"] == "account is private"` . `None` in python is equivalent of `null` in json – Moinuddin Quadri Dec 26 '20 at 18:21

0 Answers0