【问题标题】:discord python bot api call with input error?discord python bot api调用输入错误?
【发布时间】:2021-04-22 02:42:19
【问题描述】:

我正在尝试使用带有用户输入的 api 调用,但我遇到了一个错误,尝试了大约 30 分钟后仍未解决。我完全被卡住了,我之前使用过一个 api 调用,但没有用户输入(显示比特币当前价格),它运行良好,所以我不确定这里出了什么问题。

如果你能解决这个问题,将不胜感激,但如果可能的话,还请解释什么是错误的,以便我下次学习,谢谢。

@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)

如果需要,我可以提供我收到的错误消息,感谢您的帮助!

【问题讨论】:

  • 错误信息会有帮助,否则不清楚是什么问题

标签: python discord discord.py discord.py-rewrite


【解决方案1】:

我解决了我需要添加 ip 和 ipinfo 作为别名谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-05
    • 2020-12-26
    • 2021-06-12
    • 2021-02-16
    • 2021-03-31
    • 1970-01-01
    • 1970-01-01
    • 2021-04-18
    相关资源
    最近更新 更多