1
votes

I'm a newbie to python and Stackoverflow in general so please let me know if this is out of place.

Question: How do I create an embed in discord with discord.py without having to add a sub-title to the embed?

For example, here is a simplified version of my embed function:

def test_embed():
     embedPlacehold = discord.Embed(title='title', color=0xffbf00)
     embedPlacehold.add_field(name='sub-title', value='test', inline=False)
     return embedPlacehold

The section I want to remove is from line 3, name='subtitle. However, the .add_field function from discord.py needs to take that as a parameter, and the name cannot be set to an empty String.

Right now I am searching for alternative functions that do not require a subtitle to be set. I know other bots programmed from JavaScript are able to send embeds without sub-titles so I'm quite positive that there are ways to accomplish this in python too.

I've gone through a lot of the sites and still couldn't find the answer to this, so I'd appreciate any help possible!

3
although im not certain have you tried using name=Namejjoy
I just tried it and it says that "Name" is not defined.Echidna

3 Answers

4
votes

It's a strange area where Discord.py doesn't make sense, it at least cannot be avoided or left empty, however there are some ways to circumvent the problem

In this example, you can just use the bold decorator in the field you don't want, you can also use the unicode blank character which would also appear as a blank field.

def test_embed():
     embedPlacehold = discord.Embed(title='title', color=0xffbf00)
     embedPlacehold.add_field(name='sub-title', value='** **', inline=False)
     return embedPlacehold
def test_embed():
     embedPlacehold = discord.Embed(title='title', color=0xffbf00)
     embedPlacehold.add_field(name='sub-title', value='\u200b', inline=False)
     return embedPlacehold

Intead, if you would like to have a list, you could just the multi line strings, which would make the content seem as if they were without the sub-title

def test_embed():
     embedPlacehold = discord.Embed(title='title', color=0xffbf00)
     embedPlacehold.add_field(name='sub-title', value='''
     test
     test
     test
     test
     test''', inline=False)
     return embedPlacehold
0
votes

Try adding '\u200b' in your name parameter, using '\a' also works I believe.

0
votes

You can try to have an embed without any fields and use the "description" parameter in discord.Embed() to have it contain the only data that you need if that's what you're looking for!

def test_embed():
     embedPlacehold = discord.Embed(title='', description='test' color=0xffbf00)
     return embedPlacehold

this would return you an embed with just the description field without a title. However, the description might be in bold, I don't remember the exact details. Hope I was of help!