Discord.py Add embed Field without name attribute

▼魔方 西西 提交于 2021-01-28 14:01:02

问题


I want to show a Leaderboard (Place, Name, Level) in an embed TextBox. The thing is, that I HAVE TO put name='smth' in the embed.add_field function, otherwise it wont work.

But if I do so, it looks like this:

How can I delete these Titles?

My current code is

number = 0
for x in character_list:
    if number == 0:
        embed.add_field(name='Platz', value=x[0], inline=True)
        embed.add_field(name='Name', value=x[1], inline=True)
        embed.add_field(name='Level', value=x[2], inline=True)
        number = 1
    else:
        embed.add_field(name='', value=x[0], inline=True)
        embed.add_field(name='', value=x[1], inline=True)
        embed.add_field(name='', value=x[2], inline=True)
return await client.say(embed=embed)

I also tried using a fake space from utf-8 but then it looks ugly because instead of the white titles, there is just a space. I want to remove the line if its empty


回答1:


There's a zero-width whitespace character, \u200b that, if you set the field header text to, the embed will not render the field header.




回答2:


I fixed my problem doing the following method:

place = ''
name = ''
level = ''
for x in character_list:
    place += x[0] + '\n'
    name += x[1] + '\n'
    level += x[2] + '\n'
embed.add_field(name='Platz', value=place, inline=True)
embed.add_field(name='Name', value=name, inline=True)
embed.add_field(name='Level', value=level, inline=True)
return await client.say(embed=embed)



回答3:


embed.add_field(name='Title', value="\n".join([place,name,level]), inline=True)




回答4:


Just use the bold tags on a space, so something like this:

number = 0
for x in character_list:
    if number == 0:
        embed.add_field(name='Platz', value=x[0], inline=True)
        embed.add_field(name='Name', value=x[1], inline=True)
        embed.add_field(name='Level', value=x[2], inline=True)
        number = 1
    else:
        embed.add_field(name='** **', value=x[0], inline=True)
        embed.add_field(name='** **', value=x[1], inline=True)
        embed.add_field(name='** **', value=x[2], inline=True)
return await client.say(embed=embed)


来源:https://stackoverflow.com/questions/47157726/discord-py-add-embed-field-without-name-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!