Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Newline not working with lists in embedded messages - Discord.py

I have a list with newlines as variable called result

['**Status: **Enabled\n**Q: **What is 2 + 2?\n **\\ A: **4\n\n**Author: **UltimateDucc#9121\n\n\n', '**Status: **Enabled\n**Q: **Where is Ethiopia?\n **\\ A: **Africa\n\n**Author: **BigSnacc#2466\n\n\n']

When I send it as an embedded message through discord:

            l_msg = discord.Embed(
            title =  f'Page {list_msg}',
            description = str(result), 
            colour = discord.Colour.blue()
            )            
            await message.channel.send(embed = l_msg)

It comes out as this with every \n being ignored for whatever reason.

embeddedmessage

Any help is appreciated.

like image 708
ahmedquran12 Avatar asked Oct 16 '22 04:10

ahmedquran12


1 Answers

You need to convert the individual list entries into strings as opposed to just a string representation of the entire list. This is done with str.join().

Try changing the description line to:

description=''.join(result),

Result:

enter image description here

like image 145
DaveStSomeWhere Avatar answered Oct 21 '22 06:10

DaveStSomeWhere