[Economy] Add optional argument initial_balance in create_account

This commit is contained in:
Twentysix 2016-09-03 06:29:57 +02:00
parent 18b73b5969
commit 26263ee67e

View File

@ -46,7 +46,7 @@ class Bank:
self.accounts = dataIO.load_json(file_path)
self.bot = bot
def create_account(self, user):
def create_account(self, user, *, initial_balance=0):
server = user.server
if not self.account_exists(user):
if server.id not in self.accounts:
@ -54,10 +54,12 @@ class Bank:
if user.id in self.accounts: # Legacy account
balance = self.accounts[user.id]["balance"]
else:
balance = 0
balance = initial_balance
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
account = {"name" : user.name, "balance" : balance,
"created_at" : timestamp}
account = {"name" : user.name,
"balance" : balance,
"created_at" : timestamp
}
self.accounts[server.id][user.id] = account
self._save_bank()
return self.get_account(user)