Reputation: 943
this is my code -
@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)
and the above code shows the following error -
AttributeError: 'NoneType' object has no attribute 'name'
Any help will be much appreciated.
Upvotes: 0
Views: 224
Reputation: 119
Couldn't you use discord.Guild.name
instead?
This should return the name of the guild as a string
@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)```
Upvotes: 1