我的代码
@Bot.command()
async def nicknames(ctx, *, message:str=None):
embed = discord.Embed(title=f"Profile Details", description="nicknames",
color=discord.Color.green())
uuid = MojangAPI.get_uuid(f"{message}")
profile = MojangAPI.get_profile(uuid)
people = requests.get('https://api.mojang.com/user/profiles/' + uuid + '/names' )
people_json = people.json()
length = len(people_json)
for length in range(length):
embed.add_field(name="nicknames", value=people_json[length]["name"], inline=True)
await ctx.send(embed=embed)
在此处输入图像描述代码结果,但我需要一个值和一个标题中的所有名称在此处输入图像描述
在这里我找到了代码的结果如何将json文件传输到disconce.py上的嵌入中?但是的代码不起作用
若要在字符串中开始新行,请使用n
。这意味着
print("First Line!nSecond Line")
输出
First Line!
Second Line
您可以使用它在一个字段中获得昵称:
names = ""
for i in range(length):
names = names + "n" + people_json[i]["name"] #add n and the person to the string
embed.add_field(name="Nicknames", value = names, inline=True) #add the field