При прописывании команды выдает данную ошибку. Пробовал пересоздавать таблицу и переписывал код множество раз, результата не дает. Как можно ее исправить?
import disnake
from disnake.ext import commands
import sqlite3
import datetime
connection = sqlite3.connect("server.db")
cursor = connection.cursor()
class Economy(commands.Cog):
def __init__(self, bot):
self.bot = bot
#При запуске бота создает таблицы, если их раннее не было создано
@commands.Cog.listener()
async def on_ready(self):
cursor.execute("""CREATE TABLE IF NOT EXISTS users (
name TEXT,
id INT,
guild_id INT,
cash BIGINT,
rep INT,
lvl INT
)""")
connection.commit()
cursor.execute("""CREATE TABLE IF NOT EXISTS shop (
role_id INT,
id INT,
cost BIGINT
)""")
connection.commit()
#Вносит пользователя и сервер, если их раннее не было внесено в таблицу
for guild in self.bot.guilds:
for member in guild.members:
if cursor.execute(f"SELECT id, guild_id FROM users WHERE id = {member.id} and guild_id = {guild.id}").fetchone() is None:
cursor.execute(f"INSERT INTO users VALUES('{member}', {member.id}, {guild.id}, 0, 0, 1)")
else:
pass
connection.commit()
print(f"Модуль {self.__class__.__name__} загружен...")
#При присоединении участника вносит его в таблицу
@commands.Cog.listener()
async def on_member_join(self, member, guild):
if cursor.execute(f"SELECT id, guild_id FROM users WHERE id = {member.id} and guild_id = {guild.id}").fetchone() is None:
cursor.execute(f"INSERT INTO users VALUES('{member}', {member.id}, {guild.id}, 0, 0, 1)")
connection.commit()
else:
pass
#Просмотр баланса пользователя
@commands.command(name="balance", aliases=["bal"])
async def __balance(self, ctx, member: disnake.Member = None):
time_set = datetime.datetime.now()
emb1 = disnake.Embed(title = ctx.author, description=f"""**<:cristall:1096788943770501141> {cursor.execute("SELECT cash FROM users WHERE id = {} and guild_id = {}".format(ctx.author.id, ctx.guild.id)).fetchone()[0]}**\t** {cursor.execute("SELECT rep FROM users WHERE id = {} and guild_id = {}".format(ctx.author.id, ctx.guild.id)).fetchone()[0]}**""", color = 0x5a00b3)
emb1.set_author(name = ctx.author, icon_url = ctx.author.avatar)
emb1.set_thumbnail(url = ctx.author.avatar)
emb1.set_footer(text = f'{self.bot.user.name} | {time_set.strftime("%Y-%m-%d, %H:%M:%S")}', icon_url = self.bot.user.avatar)
emb2 = disnake.Embed(title = member, description=f"""**<:cristall:1096788943770501141> {cursor.execute("SELECT cash FROM users WHERE id = {} and guild_id = {}".format(member.id, ctx.guild.id)).fetchone()[0]}**\t** {cursor.execute("SELECT rep FROM users WHERE id = {} and guild_id = {}".format(member.id, ctx.guild.id)).fetchone()[0]}**""", color = 0x5a00b3)
emb2.set_author(name = ctx.author, icon_url = ctx.author.avatar)
emb2.set_thumbnail(url = member.avatar)
emb2.set_footer(text = f'{self.bot.user.name} | {time_set.strftime("%Y-%m-%d, %H:%M:%S")}', icon_url = self.bot.user.avatar)
if member is None:
if fetch := cursor.execute("SELECT cash FROM users WHERE id = {} and guild_id = {}".format(ctx.author.id, ctx.guild.id)).fetchone():
await ctx.send(embed = emb1)
else:
cursor.execute(f"INSERT INTO users VALUES('{ctx.author}', {ctx.author.id}, {ctx.guild.id}, 0, 0, 1)")
connection.commit()
await ctx.send(embed = emb1)
else:
if fetch := cursor.execute("SELECT cash FROM users WHERE id = {} and guild_id = {}".format(member.id, ctx.guild.id)).fetchone():
await ctx.send(embed = emb2)
else:
cursor.execute(f"INSERT INTO users VALUES('{member}', {member.id}, {ctx.guild.id}, 0, 0, 1)")
connection.commit()
await ctx.send(embed = emb2)