嗨,我正在尝试将.txt文件中的某些内容作为列表嵌入到嵌入中,但是我在将其显示为命令!changelog上的列表时遇到了问题。
我收到此错误:
raise HTTPException(r, data)
discord.errors.HTTPException: BAD REQUEST (status code: 400): Invalid Form Body
这是到目前为止我得到的:
@commands.command(invoke_without_command=True, case_insensitive=True)
@checks.is_channel_mod()
async def changelog(self, ctx):
changelog = open("changelog.txt").readlines()
embed = discord.Embed(description=changelog, colour=discord.Color(random.randint(0x000000, 0xFFFFFF)))
embed.title = "Changelog"
embed.set_image(url='')
await ctx.send(embed=embed)
您的帮助将不胜感激。
答案 0 :(得分:0)
用换行符加入列表:
embed = discord.Embed(description='\n'.join(changelog),
colour=discord.Color(random.randint(0x000000, 0xFFFFFF))
title='Changelog')
await ctx.send(embed=embed)
或仅使用read
代替readlines
with open("changelog.txt") as f:
changelog = f.read()
embed = discord.Embed(description=changelog,
colour=discord.Color(random.randint(0x000000, 0xFFFFFF))
title='Changelog')
await ctx.send(embed=embed)