Answer the question
In order to leave comments, you need to log in
Doesn't display role names in chat, error AttributeError: 'NoneType' object has no attribute 'mention', but id of all roles is displayed. Where is the mistake?
I am making my own economic bot. I created the !sc-shop command, it was to display all the roles from the database. But when it is executed, an error AttributeError: 'NoneType' object has no attribute 'mention' is thrown
@client.command(aliases=['shop'])
async def __shop(ctx):
embed = discord.Embed(
title='Магазин',
description='Здесь вы можете приобрести роль на сервере за **SCoins**',
color=0xCC33FF
)
for row in cursor.execute(f'SELECT role_id, cost FROM shop WHERE id = {ctx.guild.id} ORDER BY cost'):
embed.add_field(
name=f'Стоимость: **{row[1]} SCoins**',
value=f'Роль - {ctx.guild.get_role(row[0]).mention}',
inline=False
)
await ctx.send(embed = embed)
@client.command(aliases=['shop'])
async def __shop(ctx):
embed = discord.Embed(
title='Магазин',
description='Здесь вы можете приобрести роль на сервере за **SCoins**',
color=0xCC33FF
)
for row in cursor.execute(f'SELECT role_id, cost FROM shop WHERE id = {ctx.guild.id} ORDER BY cost'):
embed.add_field(
name=f'Стоимость: **{row[1]} SCoins**',
value=f'Роль - {row[0]}',
inline=False
)
await ctx.send(embed = embed)
Answer the question
In order to leave comments, you need to log in
Check type(row[0])
most likely you store/db returns ID as a string, get_role
accepts ID asint
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question