Попробывал сделать баланс пользователя но почему то выдает ошибку. Не могу понять что не так
ошибка:
Ignoring exception in command balance:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:/Users/user/Desktop/bot/1.py", line 56, in balance
await ctx.send(embed = discord.Embed(description = f"""Баланс **{ctx.author}** состовляет **{cursor.execute("SELECT cash FROM users WHERE id ={}".format(ctx.author.id)).fetchone()[0]}**"""
TypeError: 'NoneType' object is not subscriptable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'NoneType' object is not subscriptable
код:
client = commands.Bot(command_prefix = 'p!', intents = discord.Intents.all())
client.remove_command('help')
connection = sqlite3.connect('discord.db')
cursor = connection.cursor()
@client.event
async def on_ready():
cursor.execute("""CREATE TABLE IF NOT EXISTS users(name TEXT , id INT , cash BIGINT , rep INT,lvl INT)""")
connection.commit()
for guild in client.guilds:
for member in guild.members:
if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone is None:
cursor.execute(f"INSERT INTO users VALUES('{member}',{member.id},0 , 0 , 1)")
else:
pass
connection.commit()
print("bot connected")
@client.event
async def on_member_join(member):
if cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone is None:
cursor.execute(f"INSERT INTO users VALUES('{member}',{member.id}, 0, 0, 1)")
connection.commit()
else:
pass
@client.command()
async def balance(ctx ,member: discord.Member = None):
if member is None:
await ctx.send(embed = discord.Embed(description = f"""Баланс **{ctx.author}** состовляет **{cursor.execute("SELECT cash FROM users WHERE id ={}".format(ctx.author.id)).fetchone()[0]}**"""
))
else:
await ctx.send(embed = discord.Embed(description = f"""Баланс **{member}** состовляет **{cursor.execute("SELECT cash FROM users WHERE id ={}".format(member.id)).fetchone()[0]}**"""
))
В дискорде нужные галочки поставил