Discord.py嵌入文本文件,获取更多结果
我想在Discord机器人上发送嵌入的消息,但文本来自另一个文件。我这样做了,但不起作用:Discord.py嵌入文本文件,获取更多结果,discord.py,Discord.py,我想在Discord机器人上发送嵌入的消息,但文本来自另一个文件。我这样做了,但不起作用: bot.command() async def gdc(ctx): """Wins GDC""" index1 = 0 file = open("/home/plo/rkr/res_wins2", "r") for line in file.readlines():
bot.command()
async def gdc(ctx):
"""Wins GDC"""
index1 = 0
file = open("/home/plo/rkr/res_wins2", "r")
for line in file.readlines():
line = line.strip()
index1 += 1
if index1 == 4: break
message = line
embed = discord.Embed()
embed.description = message
embed.title = title
embed.colour = 0xF1C40F
await ctx.send(embed=embed)
然而,似乎只有一个结果出来了。。。以下是我的txt文件的一部分:
Roi mouton: 9
tomate: 8
The_Portos: 8
结果如下:
您正在更改for循环中每个循环的行值,因此必须列出行
lines = []
with open("/home/plo/rkr/res_wins2", "r") as file: # Use this to open and close the file
for line in file.readlines():
line = line.strip()
lines.append(line)
index1 += 1
if index1 == 4: break
embed = discord.Embed()
embed.description = '\n'.join(lines)
embed.title = title
embed.colour = 0xF1C40F
await ctx.send(embed=embed)