这是我的代码-
@client.event
async def on_guild_role_create(role):
await asyncio.sleep(10)
channel = client.get_channel(724859369732177953)
guild = client.get_guild(690494216572239922)
embed = discord.Embed(title=f"{guild.name}", description=f"**New Role Created - {role.mention}**", color=0x40cc88, timestamp=role.created_at)
embed.set_thumbnail(url=guild.icon_url)
embed.set_footer(text=f"{guild.name}")
await channel.send(embed=embed)上面的代码显示了以下错误-
AttributeError: 'NoneType' object has no attribute 'name'任何帮助都将不胜感激。
发布于 2020-07-27 00:16:52
你不能改用discord.Guild.name吗?
这应该以字符串形式返回行会的名称
@client.event
async def on_guild_role_create(role):
await asyncio.sleep(10)
channel = client.get_channel(724859369732177953)
guild = discord.Guild()
embed = discord.Embed(title=f"{guild.name}", description=f"**New Role Created - {role.mention}**", color=0x40cc88, timestamp=role.created_at)
embed.set_thumbnail(url=guild.icon_url)
embed.set_footer(text=f"{guild.name}")
await channel.send(embed=embed)```https://stackoverflow.com/questions/63102479
复制相似问题