Ignoring exception in command balance: Traceback (most recent call last): File "C:\Users\Artem\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 169, in wrapped ret = await coro(args, **kwargs) File "c:\Users\Artem\Desktop\VirenBot Discord\dsbot.py", line 42, in balance cur.execute("SELECT cash, rep FROM VirenUsers WHERE id = ?", [member.id]) File "C:\Users\Artem\AppData\Local\Programs\Python\Python310\lib\site-packages\psycopg\cursor.py", line 557, in execute raise ex.with_traceback(None) psycopg.OperationalError: the connection is closed
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\Artem\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\bot_base.py", line 570, in invoke await ctx.command.invoke(ctx) File "C:\Users\Artem\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 920, in invoke await injected(ctx.args, **ctx.kwargs) File "C:\Users\Artem\AppData\Local\Programs\Python\Python310\lib\site-packages\disnake\ext\commands\core.py", line 178, in wrapped raise CommandInvokeError(exc) from exc disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: the connection is closed
Выдаёт ошибку я не имею понятие как это исправить...Кто шарит можете помочь
```py
import psycopg
from disnake.ext import commands
import disnake
from config import settings
# Creating bot prefix
bot = commands.Bot(command_prefix = settings['prefix'], intents = disnake.Intents.all()) # guild IDs
# Connect to an existing database
with psycopg.connect("Тут секрет данные от Postgresql Python disnake.py heroku") as conn:
# Open a cursor to perform database operations
with conn.cursor() as cur:
cur.execute("""CREATE TABLE IF NOT EXISTS VirenUsers (
id INT,
cash BIGINT,
rep INT,
lvl INT,
server_id INT,
warn INT
)""")
for guild in bot.guilds:
for member in guild.members:
if member.bot:
continue # Если участник является ботом - пропускаем эту итерацию. Дальше код не выполняется
if cur.execute("SELECT id FROM VirenUsers WHERE id = ?", (member.id, )).fetchone() is None:
cur.execute("INSERT INTO VirenUsers VALUES (?, ?, ?, ?, ?, ?)", ( member.id, 0, 0, 1, guild.id, 0))
else:
pass
conn.commit()
@bot.command()
async def balance(ctx, member: disnake.Member = None):
if not member:
member = ctx.author
cur.execute("SELECT cash, rep FROM VirenUsers WHERE id = ?", [member.id])
user = cur.fetchone()
balance = disnake.Embed(
title = f"""Баланс участника - {member.name}""",
description = f"""\n• Монеты: {user[0]} :moneybag:\n• Репутация: {user[1]} :sunglasses: """
)
balance.set_footer(
text = f'Запросил: {ctx.author}',
icon_url = ctx.author.display_avatar.url
)
balance.set_thumbnail(url=member.display_avatar.url)
await ctx.send(embed=balance)
bot.run(settings['token']) # Обращаемся к словарю settings с ключом token, для получения токена```