on_guild_role_create 事件在 discord.py-rewrite v1.3.4 中不起作用

on_guild_role_create event wont work in discord.py-rewrite v1.3.4

这是我的代码 -

@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 代替吗?

这应该return公会的名称作为字符串

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