如何从文本文件添加列表以嵌入?
How to add list from text file to embed?
您好,我正在尝试将 .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)
我们将不胜感激。
用换行符加入列表:
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)
您好,我正在尝试将 .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)
我们将不胜感激。
用换行符加入列表:
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)