How to turn str into class

Solution 1:

Instead of saving the message content, you want to have to save the message id (using msg.id) inside your .ini file. This way, you're able to fetch the message object each time your bot starts up.

So instead of config["INFO"]["rods_message"] = str(msg), you will want: config["INFO"]["rods_message"] = msg.id. This way, you are saving the message id (an integer) instead of the message content (a string) in your file.

Now, in order to convert this integer into a Message object, you will have to use a few methods of discord.Client.

First, ensure that the data you are reading from the file is an integer by replacing msg = config["INFO"]["rods_message"] with msg_id = int(config["INFO"]["rods_message"])

Next, get the channel that this message is in. You can do this by putting this line of code underneath the line we just edited: channel = client.get_channel(int(config["INFO"]["discordspamChannelID"]))

Finally, this is where you convert your message id (an integer) into a message (a Message object). Underneath the previous line, add this code: msg = await channel.fetch_message(msg_id)

And that's it! You've now retrieved the original message object by using the ID of the message rather than its content.