3
votes

How do you indent texts in discord.Embed ? I want to write a custom help command for my bot and I want its fields to be indented similar to default help command. I tried a few things but none of these worked for me:

  1. I tried putting '\t' in front of description.

  2. I tried changing 'type' attribute of my embed from 'rich' to anything else during initialisation but I couldn't figure out what should I use.

  3. After my second try I thought maybe embed is in rtf format so I tried putting '\tab' in front of description.

  4. Lastly I tried putting a few spaces before description but it didn't work either.

Is there a special character/function that I should use to put indents in my embed? Or should I change the type of embed somehow? I think default help command for discord bots use different type but I am not sure. I would like to know how do I indent my embed and if there are any other types of embeds.

1
I'm not sure but the problem may be because of Discord. I know that Discord tends to strip strings as much as it can, removing leading spaces in messages and nicknames, so it might also impact Embed messages. Something you can try is using an invisible character that Discord won't strip (I could successfully indent a message manually with the 2nd method on emptycharacter.com so it's worth the try)Cyxo
I don't know if there's a proper way to indent fields but you can replace your spaces with \u200b, which is a blank character. Instead of writing it multiple times, you can do "\u200b"*20, which will be the equivalent of 20 spaces.MrSpaar
I tried but it also didn't work for me. It is probably because the type of my embed. Because default help command's embed has indents on them, also its font is different.Eren Sönmez
From the official Discord API documentation you can see that other than "rich" there aren't much types that suit your needs (article maybe?) As for discord.py auto-generated help message, they aren't Embeds, just regular messages surrounded by triple backquote ``` (which is the Markdown styling for code blocks)Cyxo
You could perhaps use special characters like this one: > <EpicRaisin

1 Answers

1
votes

Here is my solution, hope it works!

Method: '''multiline text''' https://www.geeksforgeeks.org/multi-line-printing-in-python/

Code, including other parts of the embed:

embedVar = discord.Embed(title='Testing', description='a stack overflow demo', color=0xffd800)
embedVar.set_author(name='This is an example',icon_url='https://lh3.googleusercontent.com/a-/AOh14Gh_nGxn9KBYTRFXmtEo0O9Xl1iwzD1tVsfMtdJO=k-s64')
embedVar.set_thumbnail(url="https://images-ext-1.discordapp.net/external/VbfwnzN2MM794XNccNxDzrB1YeuPrxR53y11bwRfflY/%3Fv%3D73d79a89bded/https/cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon%402.png?width=80&height=80")
embedVar.add_field(name='''hello!
    hello''', value='hello', inline=False)
#embedVar.add_field(name='', value='', inline=False)
#embedVar.set_footer(text='',icon_url='')
#embedVar.set_image(url='')
channel = bot.get_channel(<ID>)
await channel.send(embed=embedVar)

This is the field that I do multiline text.

embedVar.add_field(name='''hello!
    hello''', value='hello', inline=False)

Hope this works! My output from this code:

hello!
    hello

If it gives you this \/ error, it might be because I censored parts of the code.

discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embed.fields.0.value: This field is required

Other than that, have a good day/night and thank you for patiently reading my answer (I do not have enough reputation to comment for clarification 😩)