-
Автор темы
- #1
Всем привет. Такая проблема, что есть БАР система, которая ломается при достижение у юзера 13 лвл.
с ошибкой к консоли:
А вот и код:
с ошибкой к консоли:
А вот и код:
Python:
@client.command(aliases = ["Профиль", "профиль", "profile", "Profile"])
async def __profile(ctx, member: discord.Member=None):
if member is None:
member = ctx.author
experience = cursor.execute(f"SELECT exp FROM users WHERE id = {member.id}").fetchone()[0]
level = cursor.execute(f"SELECT lvl FROM users WHERE id = {member.id}").fetchone()[0]
current_points = experience
target_points = remaining_points(level, experience)
percent = int(24 * (current_points / target_points))
bar = '█' * percent + '░' * (24 - percent)
embed = discord.Embed(title=f"Профиль игрока", colour=discord.Colour.gold())
for row in cursor.execute("SELECT name, cash, rep, mrep, lvl, exp FROM users WHERE id = {}".format(member.id)):
roles = [role for role in member.roles]
embed.add_field(name='User-ID', value=f'`{row[0]}`', inline=True)
embed.add_field(name="Created at", value=member.created_at.strftime("%d.%m.%Y"), inline=True)
embed.add_field(name="Joined at", value=member.joined_at.strftime("%d.%m.%Y"), inline=True)
embed.add_field(name="Top role", value=member.top_role.mention, inline=True)
embed.add_field(name='Money', value=f'{row[1]:.2f} :leaves:', inline=True)
embed.add_field(name='Reputation', value=f'{row[2]} ❤ | {row[3]} 💔', inline=True)
embed.add_field(name='LVL', value=f'{row[4]} 📈', inline=True)
embed.add_field(name=f'{bar} EXP', value=f'{current_points} / {target_points} 🎓', inline=True)
await ctx.send(embed = embed)
def remaining_points(lvl, experience):
lvl_end = int(experience ** (1 / 4))
if (lvl < lvl_end):
return experience
return remaining_points(lvl, experience + 6)