I can't find a syntax error Python or use something wrong.



  • With a view to studying the peyton in practice, I'm trying to make a team that has to take a message like embed into the chat, and the user himself turns into what he wants in this message.

    In theory, the user should introduce, for example: !!em 'Title': 'Заголовок', 'Desc': 'Текст'and then everything but the team should be recorded as a mass (not in a separate file but simply in memory during the compilation) somehow:

    embedCache {
    'Title': 'Заголовок',
    'Desc': 'Текст'
    }
    

    This is the code.

    @bot.command()
    async def em(ctx, *, textE): #звёздочка в скобках указывает, что весь текст сообщения будет значением переменной textE
        embedCache = {eval(textE)}
        embedVar = discord.Embed(title=embedCache['Title'], description=embedCache['Desc'])
        await ctx.send(embed=embedVar)
    

    However, I'm being given a syntax error in the mass on the first line (not exactly, as the mass is not recorded)

    I'm sorry to make a mistake, because it's huge, I'm saying that you need to, and I think you're gonna get it.

    введите сюда описание изображения



  • Text 'Title': 'Заголовок', 'Desc': 'Текст' is not a syntaxial code, so a mistake is made. Driver.

    !!em {'Title': 'Заголовок', 'Desc': 'Текст'}

    or add brackets before sending the text eval()



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2