mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-09 04:38:55 -05:00
[Economy] Add optional argument initial_balance in create_account
This commit is contained in:
parent
18b73b5969
commit
26263ee67e
@ -46,7 +46,7 @@ class Bank:
|
|||||||
self.accounts = dataIO.load_json(file_path)
|
self.accounts = dataIO.load_json(file_path)
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
|
||||||
def create_account(self, user):
|
def create_account(self, user, *, initial_balance=0):
|
||||||
server = user.server
|
server = user.server
|
||||||
if not self.account_exists(user):
|
if not self.account_exists(user):
|
||||||
if server.id not in self.accounts:
|
if server.id not in self.accounts:
|
||||||
@ -54,10 +54,12 @@ class Bank:
|
|||||||
if user.id in self.accounts: # Legacy account
|
if user.id in self.accounts: # Legacy account
|
||||||
balance = self.accounts[user.id]["balance"]
|
balance = self.accounts[user.id]["balance"]
|
||||||
else:
|
else:
|
||||||
balance = 0
|
balance = initial_balance
|
||||||
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
account = {"name" : user.name, "balance" : balance,
|
account = {"name" : user.name,
|
||||||
"created_at" : timestamp}
|
"balance" : balance,
|
||||||
|
"created_at" : timestamp
|
||||||
|
}
|
||||||
self.accounts[server.id][user.id] = account
|
self.accounts[server.id][user.id] = account
|
||||||
self._save_bank()
|
self._save_bank()
|
||||||
return self.get_account(user)
|
return self.get_account(user)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user