@commands.Cog.listener()
async def on_dropdown(self, inter: disnake.MessageInteraction):
c = self.conn.cursor()
c.execute(f"SELECT role_id, cost FROM shop WHERE id = ?", (inter.data['values'][0],))
row = c.fetchone()
role = inter.guild.get_role(row[0])
if role in inter.author.roles:
embed = disnake.Embed(title="Магазин ролей", description=f"У вас уже есть роль {role}", color=0xFF0000)
await inter.response.send_message(embed=embed, ephemeral=True)
return
if c.execute(f"SELECT cash FROM users WHERE id = {inter.author.id}") < row[1]:
embed = disnake.Embed(title="Магазин ролей", description=f"У вас недостаточно денег для покупки роли {role_name}", color=0xFF0000)
await inter.response.send_message(embed=embed, ephemeral=True)
return
else:
c.execute(f"UPDATE users SET cash = {c.execute(f'SELECT cash FROM users WHERE id = {inter.author.id}') - row[1]} WHERE id = {inter.author.id}")
self.conn.commit()
await inter.author.add_roles(role)
embed = disnake.Embed(title="Магазин ролей", description=f"Вы успешно приобрели роль {role}", color=0x2f3136)
await inter.response.send_message(embed=embed, ephemeral=True)