Хочу проверить баланс пользователя , а бот выдает ошибку хотя на меня работает
ошибка
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\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 154, in balance
coins = fetch[0]
TypeError: 'NoneType' object is not subscriptable
Я понял что бот не регистрирует других пользователей , но почему
код
conn = sqlite3.connect("Collumn.db")
cursor = conn.cursor()
credit = '<:credit:1008003121169047553>'
@client.event
async def on_ready():
cursor.execute("""CREATE TABLE IF NOT EXISTS botmoney (id INT PRIMARY KEY,coins INT)""")
for guild in client.guilds:
for member in guild.members:
if cursor.execute(f"SELECT id FROM botmoney WHERE id = {member.id}").fetchone is None:
cursor.execute(f"INSERT INTO botmoney VALUES('{member}',{member.id},0 , 0)")
conn.commit()
print("bot connected")
@client.command()
async def balance(ctx, member: discord.Member=None):
if member is None:
cursor.execute(f"SELECT coins FROM botmoney WHERE id = {ctx.author.id}")
fetch = cursor.fetchone()
coins = fetch[0]
embed = discord.Embed(title=f'{ctx.author}',description = f'Вашь баланс :{coins}{credit}', color=random.randint(1, 16777216))
embed.set_thumbnail(url=f'{ctx.author.avatar_url}')
embed.set_image(url = 'https://c.tenor.com/-ZDK-M3lwZYAAAAd/wild-cubes-juproju.gif')
await ctx.send(embed=embed)
else:
cursor.execute(f"SELECT coins FROM botmoney WHERE id = {member.id}")
fetch = cursor.fetchone()
coins = fetch[0]
embed = discord.Embed(title=f'{member}',description = f'Его баланс: {coins}{credit}', color=random.randint(1, 16777216))
embed.set_thumbnail(url=f'{member.avatar_url}')
embed.set_image(url = 'https://c.tenor.com/c0s307LTw8AAAAAd/coin-gecko.gif')
await ctx.send(embed=embed)
Что мне именно надо заменить