хотел спросить у вас как мне решить мою проблему!
Ошибка заключается в том ,что mongodb не видит объект!
Код предоставлен ниже:
@commands.command(aliases = ['promocod', 'промокод', 'промо'])
@commands.is_owner()
async def promo(self, ctx, amount: int = None):
err = discord.utils.get(self.client.emojis, name='no')
tru = discord.utils.get(self.client.emojis, name='yes')
if amount is None:
embed = discord.Embed(
title=f'{err} Ошибка!',
description = f"Укажите промокод!",
colour=err_color
)
await ctx.send(embed=embed)
elif self.collservers.insertOne({'guild_id': ctx.guild.id, promocod: ["0"]}) < amount:
embed = discord.Embed(
title=f'{err} Ошибка!',
description = f"Промокод не найден!",
colour=err_color
)
await ctx.send(embed=embed)
elif self.collservers.insertOne({'guild_id': ctx.guild.id, promocod: ["0"]}) > amount:
embed = discord.Embed(
title=f'{err} Ошибка!',
description = f"Промокод не найден!",
colour=err_color
)
await ctx.send(embed=embed)
else:
eco = self.collservers.find({'guild_id': ctx.guild.id, promocod: ["1"]})
ispl = self.collservers.find({'guild_id': ctx.guild.id, promocod: ["2"]})
ecor = self.collection.find_one({'guild_id': ctx.guild.id, "user_id": ctx.author.id})
ispos = ispl - 1
ecore = ecor['balance'] + eco
oipl = self.collservers.update_one({'guild_id': ctx.guild.id}, {'$set':{'balance': "ecore"}})
splq = self.collservers.update_one({'guild_id': ctx.guild.id, promocod: ["2"]}, {'$set':{"2": "ispos"}})
embed = discord.Embed(
title=f'{tru} Успешно!',
description = f"Промокод активирован!\nСумма: {self.collservers.find({'guild_id': ctx.guild.id, promocod: ['1']})}",
colour=discord.Color.green()
)
await ctx.send(embed=embed)
Вот код который заносит в MongoDB:
if not self.collservers.count_documents({"guild_id": ctx.guild.id}):
post = {
"guild_id": ctx.guild.id,
"promocod": [
promo,
amount,
ispols
]
}
self.collservers.insert_one(post)