Python on_guild_role_create事件在discord.py-rewrite v1.3.4中不起作用
这是我的密码-Python on_guild_role_create事件在discord.py-rewrite v1.3.4中不起作用,python,python-3.x,discord.py,discord.py-rewrite,Python,Python 3.x,Discord.py,Discord.py Rewrite,这是我的密码- @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}", d
@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'
任何帮助都将不胜感激。您不能改用
discord.Guild.name
吗
这将以字符串形式返回公会的名称
@client.event
创建(角色)时的异步定义:
等待异步睡眠(10)
通道=客户端获取通道(724859369732177953)
guild=discord.guild()
embed=discord.embed(title=f“{guild.name}”,description=f“**新角色创建-{Role.notice}**”,color=0x40cc88,timestamp=Role.Created_at)
嵌入.set_缩略图(url=guild.icon_url)
嵌入.set_页脚(text=f“{guild.name}”)
等待通道发送(嵌入=嵌入)```