Trying to change a embed footer text with a for loop
Question:
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
Answers:
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"
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
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"