【问题标题】:Discord.py discord.Embed.from_dict not creating an embed properlyDiscord.py discord.Embed.from_dict 未正确创建嵌入
【发布时间】:2020-10-04 23:51:44
【问题描述】:
with open("C:/Users/leola/Desktop/Leo/Coding/Python/DISCORD_BOT/help_alt.json", 'r') as help_file:
        help_commands = json.load(help_file)
    # help_commands["embed"]["author"]["name"] = bot.user.display_name
    # help_commands["embed"]["footer"]["text"] = f'{curr_page}/{num_pages}'
    print(help_commands)
    help_embed = discord.Embed.from_dict(help_commands)
    await ctx.channel.send(embed=help_embed)

My json

我向 discord 上的某个人寻求帮助,他们说 json 为他们工作,他们可以从中获得嵌入,由于某种原因它对我来说坏了,并给了我一个 Can't send empty message 错误代码,当我打印出来

【问题讨论】:

  • 我找到了一个解决方法,只有一个 json,其中字段的名称和值作为 dict 中的键和值,并通过 for 循环运行它,但仍然不满意必须这样做:(

标签: python discord discord.py


【解决方案1】:

你的代码对我有用:

@bot.command()
async def gojson(ctx):
    with open('example.json', 'r') as help_file:
        help_commands = json.load(help_file)
        help_embed = discord.Embed.from_dict(help_commands)
        await ctx.channel.send(embed=help_embed)

发送完整的错误。

【讨论】:

  • 嗯,所以我再次粘贴了我的代码,所以我可以给你错误,因为我找到了一个解决方法,再次得到了 json,现在它神奇地工作了,只是......什么?
猜你喜欢
  • 2020-07-28
  • 2013-05-17
  • 2021-04-09
  • 2021-08-09
  • 2021-08-29
  • 2021-05-07
  • 2021-02-05
  • 2021-07-25
  • 2011-03-02
相关资源
最近更新 更多