Luranis
Luranis

Reputation: 161

Discord.py Add embed Field without name attribute

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: enter image description here

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

Upvotes: 7

Views: 32232

Answers (4)

Isiah
Isiah

Reputation: 315

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)

Upvotes: 1

Chris Jones
Chris Jones

Reputation: 391

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.

Upvotes: 24

akiva
akiva

Reputation: 369

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

Upvotes: 3

Luranis
Luranis

Reputation: 161

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)

Upvotes: 1

Related Questions