This is a very broad question. What you could do is store information about the bot's state in a json file, an SQL database, etc..
Example:
import json
#variables
dict ProgramState = {
"someInfo": "foo"
"someInt": 56
"someNames": ["adrian", "bob", "charlie"]
}
def save(savefilepath):
out_file = open(savefilepath, "w")
json.dump(ProgramState, out_file, indent = 4)
out_file.close()
def load(loadfilepath):
read_file = open(loadfilepath)
ProgramState = json.load(read_file)
read_file.close()
You should run save periodically, for example every time a command is called, and load whenever your program starts.