Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python on_guild_role_create事件在discord.py-rewrite v1.3.4中不起作用_Python_Python 3.x_Discord.py_Discord.py Rewrite - Fatal编程技术网

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}”)
等待通道发送(嵌入=嵌入)```