【发布时间】:2022-01-24 00:49:12
【问题描述】:
有人可以帮我解决这个错误吗,我查看了其他有相同错误但似乎无法将其应用于我的代码的错误,我不知道这是因为我不擅长编码还是因为它不能应用于我的代码,我希望人们发送更新的代码,然后他们用文字告诉我该怎么做,因为我通常不明白它
这是我的代码:
@client.command()
async def ipcheck(ctx, IP):
await ctx.send(get('https://ipapi.co/' + (IP) + '/json/').text)
这是错误:
Ignoring exception in command ipcheck:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\User\Desktop\Programming\TEST.py", line 51, in ipcheck
await ctx.send(get('https://ipapi.co/' + (IP) + '/json/').text)
AttributeError: 'str' object has no attribute 'text'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'str' object has no attribute 'text'
【问题讨论】:
标签: python error-handling discord discord.py