Ask coding questions

← Back to all posts
How can i "save" wat happened when i use the command
Pokedric (0)

Lets take "Dank memer" for example. I want the bot to remember what i have and what i did. Example: What the bot said, and for example i got 1 fish when i used the command, I want the bot to know that i have 1 fish when i use the command again.
(If you don't understand i dont blame you)

Answered by OldWizard209 (1631) [earned 5 cycles]
View Answer
OldWizard209 (1631)

You will need to use replit's database. The databse works with key-value pairs. But because your user will have more than one thing in his inventory, you can pass in a list or dicitonary.:

from replit import db

username = "BigBoiii" # Example username...

db[username] = [fish, money, boars, deers, skunks, rods, rifles.] 
# "Possible" Examples of Dank Memer Items.

# To access:
fish = int(db[username][0]) 

# Change value of fish:
fish = 1

print(f"You have {fish} fish")

So no matter how many times the bot is restarted, replit's database will save the data.

OldWizard209 (1631)

np, would mind marking the answer as correct then? @Pokedric