H
H
helpme3292020-05-25 16:28:12
Python
helpme329, 2020-05-25 16:28:12

How can such a python discord variable be implemented?

@bot.command(pass_context=True)  # разрешаем передавать агрументы
async def displayembed(ctx, arg):
  url2 = f"https://api.vimeworld.ru/user/name/{arg}"
  response2 = requests.get(url2)
  abc2 = json.loads(response2.text)
  idi = (abc2[0]["id"])
  username = (abc2[0]["username"])
  level = (abc2[0]["level"])
  levelpercentage = (abc2[0]["levelPercentage"])
  levelper2 = (int(levelpercentage) * 10)
  levelper3 = (100 - int(levelper2))
  rank = (abc2[0]["rank"])
  if rank == "PLAYER":
    don = "Игрок"
    tsvet = "0x4fffff"
  if rank == "VIP":
    don = "VIP"
    tsvet = "0x00ff00"
  if rank == "PREMIUM":
    don = "Premium"
    tsvet = "0x00ffff"
  if rank == "HOLY":
    don = "Holy"
    tsvet = "0xff8000"
  if rank == "IMMORTAL":
    tsvet = "0xff00ff"
    don = "Immortal"
  if rank == "BUILDER":
    don = "Билдер"
    tsvet = "0x00ff40"
  if rank == "MAPLEAD":
    don = "Главный билдер"
    tsvet = "0x00ff40"
  if rank == "YOUTUBE":
    don = "YouTube"
    tsvet = "0xff0000"
  if rank == "DEV":
    don = "Разработчик"
    tsvet = "0x00c1c1"
  if rank == "ORGANIZER":
    don = "Организатор"
    tsvet = "0x00c1c1"
  if rank == "MODER":
    don = "Модератор"
    tsvet = "0x0000fb"
  if rank == "WARDEN":
    don = "Проверенный модератор"
    tsvet = "0x0000fb"
  if rank == "CHIEF":
    don = "Главный модератор"
    tsvet = "0x0000fb"
  if rank == "ADMIN":
    don = "Главный админинстратор"
    tsvet = "0x00c1c1"
  else:
    don = "Не удалось определить"
    tsvet = "0x00ffff"
  playedseconds = (abc2[0]["playedSeconds"])
  minute = (int(playedseconds) / 60)
  lastSeen = (abc2[0]["lastSeen"])
  minutelast = (int(lastSeen) / 60)
  embed=discord.Embed(description="Показывает информацию об игроке", color=tsvet)
  embed.add_field(name="Игрок", value=username, inline=True)
  embed.add_field(name="Уровень", value=level, inline=True)
  embed.add_field(name="До следующего уровня", value=f"{levelper3}%", inline=True)
  embed.add_field(name="Статус", value=don, inline=True)
  embed.add_field(name="Сыграно минут", value=int(minute), inline=True)
  embed.add_field(name="Последний заход", value=int(minutelast), inline=True)
  guild = (abc2[0]["guild"])
  if guild == None:
    avatar_url = "https://avatars.mds.yandex.net/get-pdb/1101614/a41f4089-9842-4cf0-8f63-2cbb86339645/orig"
    guild = "Не в гильдии!"
    embed.add_field(name="В гильдии", value=guild, inline=True)
    embed.set_thumbnail(url="https://avatars.mds.yandex.net/get-pdb/1101614/a41f4089-9842-4cf0-8f63-2cbb86339645/orig")
  else:
    guild = "Да"
    guildid = (abc2[0]["guild"]["id"])
    guildname = (abc2[0]["guild"]["name"])
    guildtag = (abc2[0]["guild"]["tag"])
    if guildtag == None:
      guildtag = "Нет"
    guildlevel = (abc2[0]["guild"]["level"])
    guildlevelper = (abc2[0]["guild"]["levelPercentage"])
    guildlevelper2 = (int(guildlevelper) * 10)
    guildlevelper3 = (100 - int(levelper2))
    avatar_url = (abc2[0]["guild"]["avatar_url"])
    embed.add_field(name="В гильдии", value=guild, inline=True)
    embed.add_field(name="ID", value=guildid, inline=True)
    embed.add_field(name="Название гильдии", value=guildname, inline=True)
    embed.add_field(name="Тэг гильдии", value=guildtag, inline=True)
    embed.add_field(name="Уровень гильдии", value=guildlevel, inline=True)
    embed.add_field(name="До следующего уровня", value=f"{guildlevelper3}%", inline=True)
    if avatar_url == None:
        avatar_url = "https://avatars.mds.yandex.net/get-pdb/1101614/a41f4089-9842-4cf0-8f63-2cbb86339645/orig"
        embed.set_thumbnail(url=f"{avatar_url}")
    else:
        embed.set_thumbnail(url=f"{avatar_url}")
  await ctx.send(embed=embed)

There is such a code in
embed=discord.Embed(description="Shows information about the player", color=tsvet)
color=tsvet
substitute tsvet only in such a video, it does not accept it, how can I make it
most likely the answer is simple, I'm new to this deed

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-05-25
@helpme329

According to the official documentation :


color
The color code of the embed. Aliased to color as well. This can be set during initialisation.
Type
Union[Color, int]

you need to pass an int, therefore:
embed=discord.Embed(description="Показывает информацию об игроке", color=int(tsvet, 16))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question