Home > Software engineering >  Creating database files for each server that has my bot
Creating database files for each server that has my bot

Time:10-08

My bot runs a simple server economy, and the problem I'm getting is that if the bot is in multiple servers, any users added in one server also count in the other servers. Is there any way to have separate bot instances for each server its in?

CodePudding user response:

If you are using json, put the server id as the key to a dictionary that takes user id as a key :

{
"server1": {"userA":..., "userB":...}, 
"server2": {"userA":..., "userC":...},
...
}

If you are using sql, use a composed id (server user).

Note that this is one way of coding out of many.

CodePudding user response:

You can just make a dictionary with the names and the id s of the server and then regarding to the database u use, you can just take the datas from database with just calling the name of the server from dictionary. Example:

serverdic["server_name"]
  • Related