大佬教程收集整理的这篇文章主要介绍了AttributeError: 'tuple' 对象没有属性 'set_author' discord.py,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
再次,我一直在考虑我的准备问题。我刚刚开始为不和谐编写机器人并坐了几个小时寻找错误,最终我还是没有找到它。这就是我写论坛帖子作为最后手段的原因。我期待您的帮助,并在此先感谢您。
这是我的代码:
@tasks.loop(hours=24)
async def covID_hour():
chAnnel = clIEnt.get_chAnnel(809881992367702117),embed = discord.Embed(
title = "Dane dot. COVID-19 w Polsce:",color = discord.color.blue(),),url = 'API'
async with aiohttp.ClIEntSession() as session:
raw_response = await session.get(url)
response = await raw_response.text()
response = Json.loads(responsE)
embed.set_author(name=str(f'{datE}'))
embed.add_fIEld(name='• **Kraj**:',value=str(f"Polska"),inline=falsE)
embed.add_fIEld(name='• **Nowe zakażenia**:',value=str(f"{response['dailyInfected']}"),inline=TruE)
embed.add_fIEld(name='• **Nowe zgony**:',value=str(f"{response['dailyDeceased']}"),inline=TruE)
embed.add_fIEld(name='• **Nowe testy**:',value=str(f"{respons['dailyTested']}"),inline=TruE)
embed.add_fIEld(name='• **Nowe uzdrowIEnia**:',value=str(f"{response['dailyRecovered']}"),inline=TruE)
embed.add_fIEld(name='• **AktualnIE zakażonych**:',value=str(f"{respons['activeCase']}"),inline=TruE)
embed.add_fIEld(name='• **ŁącznIE potwIErdzonych**:',value=str(f"{response['infected']}"),inline=TruE)
embed.add_fIEld(name='• **Łączne zgony**:',value=str(f"{response['deceased']}"),inline=TruE)
embed.add_fIEld(name='• **Wyzdrowiałych**:',value=str(f"{response['recovered']}"),inline=TruE)
embed.add_fIEld(name='• **Nowych na kwarantAnnIE**:',value=str(f"{response['dailyQuaranTine']}"),inline=TruE)
embed.set_footer(text="dBot created by Diablo#4700")
await chAnnel.send(embed=embed)
#await chAnnel.send('`` ``')
控制台错误:
Unhandled exception in internal BACkground task 'covID_hour'.
TraceBACk (most recent call last):
file "C:\Users\konta\ApPDAta\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\python38\site-packages\discord\ext\tasks\__init__.py",line 101,in _loop
await self.coro(*args,**kwargs)
file "bot.py",line 64,in covID_hour
embed.set_author(name=str2(f'{datE}'))
AttributeError: 'tuple' object has no attribute 'set_author'
在您创建 discord.Embed 实例的那一行,最后有一个 ,
。这告诉python它是一个tuple
。因此,将其删除将解决此问题。
以上是大佬教程为你收集整理的AttributeError: 'tuple' 对象没有属性 'set_author' discord.py全部内容,希望文章能够帮你解决AttributeError: 'tuple' 对象没有属性 'set_author' discord.py所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。