Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trying to change a embed footer text with a for loop

for footer in embed_dict["footer"]:
    footer["text"] = "new text"
embed_new = discord.Embed.from_dict(embed_dict)
await messageraids.edit(embed=raidedit1embed) 

I get the error:

footer["text"] = "new text"
TypeError: 'str' object does not support item assignment

Anyone know how to fix this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Based on your comment clarifying that embed_dict["footer"] contains {'text': '0/10 Total'}, your problem is you’re iterating over that value in the line:

for footer in embed_dict["footer"]:

Doing so iterates over the keys of that dictionary, so footer has a value of 'text', and you’re doing footer["text"] = "new text", which you can’t do on a string. You should simply do:

embed_dict["footer"]["text"] = "new text"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading