简体   繁体   English

discord python bot api 调用输入错误?

[英]discord python bot api call with input error?

I'm trying to use an api call with user input and I have got an error that hasn't been solved in about 30 minutes of trying.我正在尝试使用带有用户输入的 api 调用,但我遇到了一个在大约 30 分钟的尝试后仍未解决的错误。 I'm completely stuck, I used an api call before but without user input (showed bitcoin current price) and it worked perfect so I'm not sure what has gone wrong here.我完全被卡住了,我之前使用过 api 调用,但没有用户输入(显示比特币当前价格),它运行良好,所以我不确定这里出了什么问题。

If you can fix this, it would be very grateful, but if possible also explain what was wrong so I'll learn for next time thanks.如果您能解决此问题,将不胜感激,但如果可能的话,还请解释出了什么问题,以便我下次学习谢谢。

@client.command()
async def ipinfo(ctx, ip):
    url = ('http://ip-api.com/json/' + ip)

    response = requests.get(url)
    country = response.json()['country']
    city = response.json()['city']
    embed = discord.Embed(color=discord.Color.red(), title="IP info for " + ip)
    embed.add_field(name="Country", value=f'{country}', inline=False)
    embed.add_field(name="City", value=f"{city}", inline=False)

    await ctx.send(embed=embed)

I can provide the error message I get if needed, thanks for any help!如果需要,我可以提供我收到的错误消息,感谢您的帮助!

i worked it out i needed to add ip and ipinfo as aliases thank you.我解决了我需要添加 ip 和 ipinfo 作为别名谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM