mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 19:58:54 -05:00
[Economy] Added [p]economyset registercredits (#472)
Allows to set initial credits for new bank accounts
This commit is contained in:
parent
5ae98a046e
commit
c23cadda44
@ -11,7 +11,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
default_settings = {"PAYDAY_TIME" : 300, "PAYDAY_CREDITS" : 120, "SLOT_MIN" : 5, "SLOT_MAX" : 100, "SLOT_TIME" : 0}
|
default_settings = {"PAYDAY_TIME" : 300, "PAYDAY_CREDITS" : 120, "SLOT_MIN" : 5, "SLOT_MAX" : 100, "SLOT_TIME" : 0, "REGISTER_CREDITS" : 0}
|
||||||
|
|
||||||
slot_payouts = """Slot machine payouts:
|
slot_payouts = """Slot machine payouts:
|
||||||
:two: :two: :six: Bet * 5000
|
:two: :two: :six: Bet * 5000
|
||||||
@ -220,8 +220,11 @@ class Economy:
|
|||||||
async def register(self, ctx):
|
async def register(self, ctx):
|
||||||
"""Registers an account at the Twentysix bank"""
|
"""Registers an account at the Twentysix bank"""
|
||||||
user = ctx.message.author
|
user = ctx.message.author
|
||||||
|
credits = 0
|
||||||
|
if ctx.message.server.id in self.settings:
|
||||||
|
credits = self.settings[ctx.message.server.id].get("REGISTER_CREDITS", 0)
|
||||||
try:
|
try:
|
||||||
account = self.bank.create_account(user)
|
account = self.bank.create_account(user, initial_balance=credits)
|
||||||
await self.bot.say("{} Account opened. Current balance: {}".format(user.mention,
|
await self.bot.say("{} Account opened. Current balance: {}".format(user.mention,
|
||||||
account.balance))
|
account.balance))
|
||||||
except AccountAlreadyExists:
|
except AccountAlreadyExists:
|
||||||
@ -501,6 +504,16 @@ class Economy:
|
|||||||
await self.bot.say("Every payday will now give " + str(credits) + " credits.")
|
await self.bot.say("Every payday will now give " + str(credits) + " credits.")
|
||||||
dataIO.save_json(self.file_path, self.settings)
|
dataIO.save_json(self.file_path, self.settings)
|
||||||
|
|
||||||
|
@economyset.command(pass_context=True)
|
||||||
|
async def registercredits(self, ctx, credits : int):
|
||||||
|
"""Credits given on registering an account"""
|
||||||
|
server = ctx.message.server
|
||||||
|
if credits < 0:
|
||||||
|
credits = 0
|
||||||
|
self.settings[server.id]["REGISTER_CREDITS"] = credits
|
||||||
|
await self.bot.say("Registering an account will now give {} credits.".format(credits))
|
||||||
|
dataIO.save_json(self.file_path, self.settings)
|
||||||
|
|
||||||
def display_time(self, seconds, granularity=2): # What would I ever do without stackoverflow?
|
def display_time(self, seconds, granularity=2): # What would I ever do without stackoverflow?
|
||||||
intervals = ( # Source: http://stackoverflow.com/a/24542445
|
intervals = ( # Source: http://stackoverflow.com/a/24542445
|
||||||
('weeks', 604800), # 60 * 60 * 24 * 7
|
('weeks', 604800), # 60 * 60 * 24 * 7
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user