TypeError: 'property' object is not iterable
недавно разбил код на Cogs, и в итоге перестала работать часть кода, выдавая ошибку: TypeError: 'property' object is not iterable. Я как только не пытался, помогите пожалуйста, код прикрепляю ниже:
import discord
from discord.ext import commands
from discord.ext.commands import Bot
from Cybernator import Paginator
import sqlite3
class Eco(commands.Cog):
def __init__(self, Bot):
self.Bot = Bot
self.connection = sqlite3.connect('server.db')
self.cursor = self.connection.cursor()
@commands.Cog.listener()
async def on_ready(self):
self.cursor.execute("""CREATE TABLE IF NOT EXISTS users (
name TEXT,
id INT,
cash BIGINT,
rep INT,
lvl INT
)""")
self.cursor.execute("""CREATE TABLE IF NOT EXISTS shop (
role_id INT,
id INT,
cost BIGINT
)""")
for guild in Bot.guilds:
for member in guild.members:
if self.cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
self.cursor.execute(f"INSERT INTO users VALUES ('{member}', {member.id}, 0, 0, 1)")
self.connection.commit()
else:
pass
connection.commit()
@commands.Cog.listener()
async def on_member_join(self, member):
if self.cursor.execute(f"SELECT id FROM users WHERE id = {member.id}").fetchone() is None:
self.cursor.execute(f"INSERT INTO users VALUES ('{member}', {member.id}, 0, 0, 1)")
self.connection.commit()
else:
pass
@commands.command()
async def balance(self, ctx, member: discord.Member = None):
if member is None:
await ctx.send(embed = discord.Embed(
description = f"""Баланс пользователя **{ctx.author}** составяляет **{self.cursor.execute("SELECT cash FROM users WHERE id = {}".format(ctx.author.id)).fetchone()[0]} :leaves:**"""
))
else:
await ctx.send(embed = discord.Embed(
description = f"""Баланс пользователя **{member}** составяляет **{self.cursor.execute("SELECT cash FROM users WHERE id = {}".format(member.id)).fetchone()[0]} :leaves:**"""
))
@commands.command()
async def award(self, ctx, member:discord.Member = None, amount: int = None):
if member is None:
await ctx.send(embed = discord.Embed(
description = f"**{ctx.author}**, укажите пользователя, которому желаете выдать сумму"))
else:
if amount is None:
await ctx.send(embed = discord.Embed(
description = f"**{ctx.author}**, укажите сумму, которую желаете выдать."))
elif amount < 1:
await ctx.send(embed = discord.Embed(
description = f"**{ctx.author}**, укажите сумму больше 1."))
else:
self.cursor.execute("UPDATE users SET cash = cash + {} WHERE id = {}".format(amount, member.id))
self.connection.commit()
await ctx.message.add_reaction('?')
@commands.command()
async def take(self, ctx, member: discord.Member = None, amount = None):
if member is None:
await ctx.send(embed = discord.Embed(
description = f"**{ctx.author}**, укажите пользователя, которому желаете отнять сумму"))
else:
if amount is None:
await ctx.send(embed = discord.Embed(
description = f"**{ctx.author}**, укажите сумму, которую желаете убрать."))
elif amount == 'all':
self.cursor.execute("UPDATE users SET cash = cash = {} WHERE id = {}".format(0, member.id))
self.connection.commit()
await ctx.message.add_reaction('?')
elif int(amount) < 1:
await ctx.send(embed = discord.Embed(
description = f"**{ctx.author}**, укажите сумму больше 1."))
else:
self.cursor.execute("UPDATE users SET cash = cash - {} WHERE id = {}".format(int(amount), member.id))
self.connection.commit()
await ctx.message.add_reaction('?')
@commands.command(aliases = ['add-shop'])
async def __add_shop(self, ctx, role: discord.Role = None, cost: int = None):
if role is None:
await ctx.send(f"**{ctx.author}**, укажите роль, которую вы желаете внести в магазин")
else:
if cost is None:
await ctx.send(f"**{ctx.author}**, укажите стоимость для данной роли")
elif cost < 0:
await ctx.send(f"**{ctx.author}**, стоимость роли не может быть такой маленькой")
else:
self.cursor.execute("INSERT INTO shop VALUES ({}, {}, {})".format(role.id, ctx.guild.id, cost))
self.connection.commit()
await ctx.message.add_reaction('?')
@commands.command(aliases = ['remove-shop'])
async def __remove_shop(self, ctx, role: discord.Role = None):
if role is None:
await ctx.send(f"**{ctx.author}**, укажите роль, которую вы желаете удалить из магазина")
else:
self.cursor.execute("DELETE FROM shop WHERE role_id = {}".format(role.id))
self.connection.commit()
await ctx.message.add_reaction('?')
@commands.command(aliases = ['shop'])
async def __shop(self, ctx):
embed = discord.Embed(title = 'Магазин ролей')
for row in self.cursor.execute("SELECT role_id, cost FROM shop WHERE id = {}".format(ctx.guild.id)):
if ctx.guild.get_role(row[0]) != None:
embed.add_field(
name = f"Стоимость **{row[1]} :leaves:**",
value = f"Вы приобрете роль {ctx.guild.get_role(row[0]).mention}",
inline = False
)
else:
pass
await ctx.send(embed = embed)
@commands.command(aliases = ['buy', 'buy-role'])
async def __buy(self, ctx, role: discord.Role = None):
if role is None:
await ctx.send(f"**{ctx.author}**, укажите роль, которую вы желаете приобрести")
else:
if role in ctx.author.roles:
await ctx.send(f"**{ctx.author}**, у вас уже имеется данная роль")
elif self.cursor.execute("SELECT cost FROM shop WHERE role_id = {}".format(role.id)).fetchone()[0] > self.cursor.execute("SELECT cash FROM users WHERE id = {}".format(ctx.author.id)).fetchone()[0]:
await ctx.send(f"**{ctx.author}**, у вас недостаточно средств для покупки данной роли")
else:
await ctx.author.add_roles(role)
self.cursor.execute("UPDATE users SET cash = cash - {} WHERE id = {}".format(self.cursor.execute("SELECT cost FROM shop WHERE role_id = {}".format(role.id)).fetchone()[0], ctx.author.id))
connection.commit()
await ctx.message.add_reaction('?')
@commands.command()
async def trade(self, ctx, member: discord.Member = None, role: discord.Role = None):
if role is None:
await ctx.send(embed = discord.Embed(
description = "Укажите пользователя, которому желаете передать роль"))
else:
if member is None:
await ctx.send(embed = discord.Embed(
description = "Укажите роль, которую желаете обменять."))
else:
if role in member.roles:
ctx.send(f"**{ctx.author}**, у пользователя имеется уже данная роль.")
elif role in ctx.author.roles:
await ctx.author.remove_roles(role)
await member.add_roles(role)
await ctx.message.add_reaction('?')
def setup(Bot):
Bot.add_cog(Eco(Bot))
