@NeW_CodeR
Аферюга

Создаю бота на Discord.py + SQLite3. В чём здесь ошибка?

Вот обычный код:
# -*- coding: utf-8 -*-
import discord
from discord.ext import commands
import random
import asyncio
from asyncio import sleep
from discord_components import DiscordComponents, Button, ButtonStyle
from random import choice
import datetime
import re
import sqlite3

client = discord.ext.commands.Bot( command_prefix = '|', case_insensitive=True, intents = discord.Intents.all())
client.remove_command('help')

determine_flip = [1, 0]
datetime.datetime.utcnow()

# ЭКОНОМИКА, ЧУВАК!

connection = sqlite3.connect('server.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()
    print('РАБОТАЕТ УХААХАХАХ')

    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 VANUES ('{member}', {member.id}, 0, 0, 0)")
                connection.commit()
            else:
                pass

@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 VANUES ('{member}', {member.id}, 0, 0, 0)")
    else:
        pass

@client.command(aliases= ['баланс', 'бал', 'балик'])
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]}` :cash:"""
        ))
    else:
        await ctx.send(embed=discord.Embed(
            description=f"""Баланс пользователя **{member}** составляет `{cursor.execute("SELECT cash FROM users WHERE id = {}".format(ctx.member.id)).fetchone()[0]}` :cash:"""
        ))

ОШИБКА:
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: OperationalError: no such column: cash
  • Вопрос задан
  • 135 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы