mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-09 12:48:54 -05:00
[Economy] Leaderboard pagify (#475)
* Some PEP8 stuff * pagify leaderboard
This commit is contained in:
parent
d349a0cab7
commit
8a7be3b812
163
cogs/economy.py
163
cogs/economy.py
@ -6,12 +6,15 @@ from datetime import datetime
|
|||||||
from random import randint
|
from random import randint
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from .utils import checks
|
from .utils import checks
|
||||||
|
from cogs.utils.chat_formatting import pagify, box
|
||||||
from __main__ import send_cmd_help
|
from __main__ import send_cmd_help
|
||||||
import os
|
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, "REGISTER_CREDITS" : 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
|
||||||
@ -49,6 +52,7 @@ class SameSenderAndReceiver(BankError):
|
|||||||
|
|
||||||
|
|
||||||
class Bank:
|
class Bank:
|
||||||
|
|
||||||
def __init__(self, bot, file_path):
|
def __init__(self, bot, file_path):
|
||||||
self.accounts = dataIO.load_json(file_path)
|
self.accounts = dataIO.load_json(file_path)
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
@ -154,8 +158,10 @@ class Bank:
|
|||||||
accounts = []
|
accounts = []
|
||||||
for server_id, v in self.accounts.items():
|
for server_id, v in self.accounts.items():
|
||||||
server = self.bot.get_server(server_id)
|
server = self.bot.get_server(server_id)
|
||||||
if server is None:# Servers that have since been left will be ignored
|
if server is None:
|
||||||
continue # Same for users_id from the old bank format
|
# Servers that have since been left will be ignored
|
||||||
|
# Same for users_id from the old bank format
|
||||||
|
continue
|
||||||
raw_server_accounts = deepcopy(self.accounts[server.id])
|
raw_server_accounts = deepcopy(self.accounts[server.id])
|
||||||
for k, v in raw_server_accounts.items():
|
for k, v in raw_server_accounts.items():
|
||||||
v["id"] = k
|
v["id"] = k
|
||||||
@ -192,6 +198,7 @@ class Bank:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
raise NoAccount()
|
raise NoAccount()
|
||||||
|
|
||||||
|
|
||||||
class Economy:
|
class Economy:
|
||||||
"""Economy
|
"""Economy
|
||||||
|
|
||||||
@ -224,11 +231,18 @@ class Economy:
|
|||||||
if ctx.message.server.id in self.settings:
|
if ctx.message.server.id in self.settings:
|
||||||
credits = self.settings[ctx.message.server.id].get("REGISTER_CREDITS", 0)
|
credits = self.settings[ctx.message.server.id].get("REGISTER_CREDITS", 0)
|
||||||
try:
|
try:
|
||||||
|
<<<<<<< HEAD
|
||||||
account = self.bank.create_account(user, initial_balance=credits)
|
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))
|
||||||
|
=======
|
||||||
|
account = self.bank.create_account(user)
|
||||||
|
await self.bot.say("{} Account opened. Current balance: {}".format(
|
||||||
|
user.mention, account.balance))
|
||||||
|
>>>>>>> cb472f9... Some PEP8 stuff
|
||||||
except AccountAlreadyExists:
|
except AccountAlreadyExists:
|
||||||
await self.bot.say("{} You already have an account at the Twentysix bank.".format(user.mention))
|
await self.bot.say("{} You already have an account at the"
|
||||||
|
" Twentysix bank.".format(user.mention))
|
||||||
|
|
||||||
@_bank.command(pass_context=True)
|
@_bank.command(pass_context=True)
|
||||||
async def balance(self, ctx, user: discord.Member=None):
|
async def balance(self, ctx, user: discord.Member=None):
|
||||||
@ -238,13 +252,17 @@ class Economy:
|
|||||||
if not user:
|
if not user:
|
||||||
user = ctx.message.author
|
user = ctx.message.author
|
||||||
try:
|
try:
|
||||||
await self.bot.say("{} Your balance is: {}".format(user.mention, self.bank.get_balance(user)))
|
await self.bot.say("{} Your balance is: {}".format(
|
||||||
|
user.mention, self.bank.get_balance(user)))
|
||||||
except NoAccount:
|
except NoAccount:
|
||||||
await self.bot.say("{} You don't have an account at the Twentysix bank."
|
await self.bot.say("{} You don't have an account at the"
|
||||||
" Type `{}bank register` to open one.".format(user.mention, ctx.prefix))
|
" Twentysix bank. Type `{}bank register`"
|
||||||
|
" to open one.".format(user.mention,
|
||||||
|
ctx.prefix))
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
await self.bot.say("{}'s balance is {}".format(user.name, self.bank.get_balance(user)))
|
await self.bot.say("{}'s balance is {}".format(
|
||||||
|
user.name, self.bank.get_balance(user)))
|
||||||
except NoAccount:
|
except NoAccount:
|
||||||
await self.bot.say("That user has no bank account.")
|
await self.bot.say("That user has no bank account.")
|
||||||
|
|
||||||
@ -256,7 +274,8 @@ class Economy:
|
|||||||
self.bank.transfer_credits(author, user, sum)
|
self.bank.transfer_credits(author, user, sum)
|
||||||
logger.info("{}({}) transferred {} credits to {}({})".format(
|
logger.info("{}({}) transferred {} credits to {}({})".format(
|
||||||
author.name, author.id, sum, user.name, user.id))
|
author.name, author.id, sum, user.name, user.id))
|
||||||
await self.bot.say("{} credits have been transferred to {}'s account.".format(sum, user.name))
|
await self.bot.say("{} credits have been transferred to {}'s"
|
||||||
|
" account.".format(sum, user.name))
|
||||||
except NegativeValue:
|
except NegativeValue:
|
||||||
await self.bot.say("You need to transfer at least 1 credit.")
|
await self.bot.say("You need to transfer at least 1 credit.")
|
||||||
except SameSenderAndReceiver:
|
except SameSenderAndReceiver:
|
||||||
@ -275,8 +294,10 @@ class Economy:
|
|||||||
author = ctx.message.author
|
author = ctx.message.author
|
||||||
try:
|
try:
|
||||||
self.bank.set_credits(user, sum)
|
self.bank.set_credits(user, sum)
|
||||||
logger.info("{}({}) set {} credits to {} ({})".format(author.name, author.id, str(sum), user.name, user.id))
|
logger.info("{}({}) set {} credits to {} ({})".format(
|
||||||
await self.bot.say("{}'s credits have been set to {}".format(user.name, str(sum)))
|
author.name, author.id, str(sum), user.name, user.id))
|
||||||
|
await self.bot.say("{}'s credits have been set to {}".format(
|
||||||
|
user.name, str(sum)))
|
||||||
except NoAccount:
|
except NoAccount:
|
||||||
await self.bot.say("User has no bank account.")
|
await self.bot.say("User has no bank account.")
|
||||||
|
|
||||||
@ -288,19 +309,36 @@ class Economy:
|
|||||||
id = author.id
|
id = author.id
|
||||||
if self.bank.account_exists(author):
|
if self.bank.account_exists(author):
|
||||||
if id in self.payday_register[server.id]:
|
if id in self.payday_register[server.id]:
|
||||||
seconds = abs(self.payday_register[server.id][id] - int(time.perf_counter()))
|
seconds = abs(self.payday_register[server.id][
|
||||||
|
id] - int(time.perf_counter()))
|
||||||
if seconds >= self.settings[server.id]["PAYDAY_TIME"]:
|
if seconds >= self.settings[server.id]["PAYDAY_TIME"]:
|
||||||
self.bank.deposit_credits(author, self.settings[server.id]["PAYDAY_CREDITS"])
|
self.bank.deposit_credits(author, self.settings[
|
||||||
self.payday_register[server.id][id] = int(time.perf_counter())
|
server.id]["PAYDAY_CREDITS"])
|
||||||
await self.bot.say("{} Here, take some credits. Enjoy! (+{} credits!)".format(author.mention, str(self.settings[server.id]["PAYDAY_CREDITS"])))
|
self.payday_register[server.id][
|
||||||
|
id] = int(time.perf_counter())
|
||||||
|
await self.bot.say(
|
||||||
|
"{} Here, take some credits. Enjoy! (+{}"
|
||||||
|
" credits!)".format(
|
||||||
|
author.mention,
|
||||||
|
str(self.settings[server.id]["PAYDAY_CREDITS"])))
|
||||||
else:
|
else:
|
||||||
await self.bot.say("{} Too soon. For your next payday you have to wait {}.".format(author.mention, self.display_time(self.settings[server.id]["PAYDAY_TIME"] - seconds)))
|
dtime = self.display_time(
|
||||||
|
self.settings[server.id]["PAYDAY_TIME"] - seconds)
|
||||||
|
await self.bot.say(
|
||||||
|
"{} Too soon. For your next payday you have to"
|
||||||
|
" wait {}.".format(author.mention, dtime))
|
||||||
else:
|
else:
|
||||||
self.payday_register[server.id][id] = int(time.perf_counter())
|
self.payday_register[server.id][id] = int(time.perf_counter())
|
||||||
self.bank.deposit_credits(author, self.settings[server.id]["PAYDAY_CREDITS"])
|
self.bank.deposit_credits(author, self.settings[
|
||||||
await self.bot.say("{} Here, take some credits. Enjoy! (+{} credits!)".format(author.mention, str(self.settings[server.id]["PAYDAY_CREDITS"])))
|
server.id]["PAYDAY_CREDITS"])
|
||||||
|
await self.bot.say(
|
||||||
|
"{} Here, take some credits. Enjoy! (+{} credits!)".format(
|
||||||
|
author.mention,
|
||||||
|
str(self.settings[server.id]["PAYDAY_CREDITS"])))
|
||||||
else:
|
else:
|
||||||
await self.bot.say("{} You need an account to receive credits. Type `{}bank register` to open one.".format(author.mention, ctx.prefix))
|
await self.bot.say("{} You need an account to receive credits."
|
||||||
|
" Type `{}bank register` to open one.".format(
|
||||||
|
author.mention, ctx.prefix))
|
||||||
|
|
||||||
@commands.group(pass_context=True)
|
@commands.group(pass_context=True)
|
||||||
async def leaderboard(self, ctx):
|
async def leaderboard(self, ctx):
|
||||||
@ -314,7 +352,8 @@ class Economy:
|
|||||||
async def _server_leaderboard(self, ctx, top: int=10):
|
async def _server_leaderboard(self, ctx, top: int=10):
|
||||||
"""Prints out the server's leaderboard
|
"""Prints out the server's leaderboard
|
||||||
|
|
||||||
Defaults to top 10""" #Originally coded by Airenkun - edited by irdumb
|
Defaults to top 10"""
|
||||||
|
# Originally coded by Airenkun - edited by irdumb
|
||||||
server = ctx.message.server
|
server = ctx.message.server
|
||||||
if top < 1:
|
if top < 1:
|
||||||
top = 10
|
top = 10
|
||||||
@ -330,11 +369,9 @@ class Economy:
|
|||||||
highscore += (acc.name + " ").ljust(23 - len(str(acc.balance)))
|
highscore += (acc.name + " ").ljust(23 - len(str(acc.balance)))
|
||||||
highscore += str(acc.balance) + "\n"
|
highscore += str(acc.balance) + "\n"
|
||||||
place += 1
|
place += 1
|
||||||
if highscore:
|
if highscore != "":
|
||||||
if len(highscore) < 1985:
|
for page in pagify(highscore, shorten_by=12):
|
||||||
await self.bot.say("```py\n"+highscore+"```")
|
await self.bot.say(box(page, lang="py"))
|
||||||
else:
|
|
||||||
await self.bot.say("The leaderboard is too big to be displayed. Try with a lower <top> parameter.")
|
|
||||||
else:
|
else:
|
||||||
await self.bot.say("There are no accounts in the bank.")
|
await self.bot.say("There are no accounts in the bank.")
|
||||||
|
|
||||||
@ -358,14 +395,13 @@ class Economy:
|
|||||||
place = 1
|
place = 1
|
||||||
for acc in topten:
|
for acc in topten:
|
||||||
highscore += str(place).ljust(len(str(top)) + 1)
|
highscore += str(place).ljust(len(str(top)) + 1)
|
||||||
highscore += ("{} |{}| ".format(acc.name, acc.server.name)).ljust(23-len(str(acc.balance)))
|
highscore += ("{} |{}| ".format(acc.name, acc.server.name)
|
||||||
|
).ljust(23 - len(str(acc.balance)))
|
||||||
highscore += str(acc.balance) + "\n"
|
highscore += str(acc.balance) + "\n"
|
||||||
place += 1
|
place += 1
|
||||||
if highscore:
|
if highscore != "":
|
||||||
if len(highscore) < 1985:
|
for page in pagify(highscore, shorten_by=12):
|
||||||
await self.bot.say("```py\n"+highscore+"```")
|
await self.bot.say(box(page, lang="py"))
|
||||||
else:
|
|
||||||
await self.bot.say("The leaderboard is too big to be displayed. Try with a lower <top> parameter.")
|
|
||||||
else:
|
else:
|
||||||
await self.bot.say("There are no accounts in the bank.")
|
await self.bot.say("There are no accounts in the bank.")
|
||||||
|
|
||||||
@ -392,7 +428,8 @@ class Economy:
|
|||||||
if bid >= self.settings[server.id]["SLOT_MIN"] and bid <= self.settings[server.id]["SLOT_MAX"]:
|
if bid >= self.settings[server.id]["SLOT_MIN"] and bid <= self.settings[server.id]["SLOT_MAX"]:
|
||||||
if author.id in self.slot_register:
|
if author.id in self.slot_register:
|
||||||
if abs(self.slot_register[author.id] - int(time.perf_counter())) >= self.settings[server.id]["SLOT_TIME"]:
|
if abs(self.slot_register[author.id] - int(time.perf_counter())) >= self.settings[server.id]["SLOT_TIME"]:
|
||||||
self.slot_register[author.id] = int(time.perf_counter())
|
self.slot_register[author.id] = int(
|
||||||
|
time.perf_counter())
|
||||||
await self.slot_machine(ctx.message, bid)
|
await self.slot_machine(ctx.message, bid)
|
||||||
else:
|
else:
|
||||||
await self.bot.say("Slot machine is still cooling off! Wait {} seconds between each pull".format(self.settings[server.id]["SLOT_TIME"]))
|
await self.bot.say("Slot machine is still cooling off! Wait {} seconds between each pull".format(self.settings[server.id]["SLOT_TIME"]))
|
||||||
@ -405,8 +442,10 @@ class Economy:
|
|||||||
await self.bot.say("{0} You need an account with enough funds to play the slot machine.".format(author.mention))
|
await self.bot.say("{0} You need an account with enough funds to play the slot machine.".format(author.mention))
|
||||||
|
|
||||||
async def slot_machine(self, message, bid):
|
async def slot_machine(self, message, bid):
|
||||||
reel_pattern = [":cherries:", ":cookie:", ":two:", ":four_leaf_clover:", ":cyclone:", ":sunflower:", ":six:", ":mushroom:", ":heart:", ":snowflake:"]
|
reel_pattern = [":cherries:", ":cookie:", ":two:", ":four_leaf_clover:",
|
||||||
padding_before = [":mushroom:", ":heart:", ":snowflake:"] # padding prevents index errors
|
":cyclone:", ":sunflower:", ":six:", ":mushroom:", ":heart:", ":snowflake:"]
|
||||||
|
# padding prevents index errors
|
||||||
|
padding_before = [":mushroom:", ":heart:", ":snowflake:"]
|
||||||
padding_after = [":cherries:", ":cookie:", ":two:"]
|
padding_after = [":cherries:", ":cookie:", ":two:"]
|
||||||
reel = padding_before + reel_pattern + padding_after
|
reel = padding_before + reel_pattern + padding_after
|
||||||
reels = []
|
reels = []
|
||||||
@ -415,39 +454,54 @@ class Economy:
|
|||||||
reels.append([reel[n - 1], reel[n], reel[n + 1]])
|
reels.append([reel[n - 1], reel[n], reel[n + 1]])
|
||||||
line = [reels[0][1], reels[1][1], reels[2][1]]
|
line = [reels[0][1], reels[1][1], reels[2][1]]
|
||||||
|
|
||||||
display_reels = "~~\n~~ " + reels[0][0] + " " + reels[1][0] + " " + reels[2][0] + "\n"
|
display_reels = "~~\n~~ " + \
|
||||||
display_reels += ">" + reels[0][1] + " " + reels[1][1] + " " + reels[2][1] + "\n"
|
reels[0][0] + " " + reels[1][0] + " " + reels[2][0] + "\n"
|
||||||
display_reels += " " + reels[0][2] + " " + reels[1][2] + " " + reels[2][2] + "\n"
|
display_reels += ">" + reels[0][1] + " " + \
|
||||||
|
reels[1][1] + " " + reels[2][1] + "\n"
|
||||||
|
display_reels += " " + reels[0][2] + " " + \
|
||||||
|
reels[1][2] + " " + reels[2][2] + "\n"
|
||||||
|
|
||||||
if line[0] == ":two:" and line[1] == ":two:" and line[2] == ":six:":
|
if line[0] == ":two:" and line[1] == ":two:" and line[2] == ":six:":
|
||||||
bid = bid * 5000
|
bid = bid * 5000
|
||||||
slotMsg = "{}{} 226! Your bet is multiplied * 5000! {}! ".format(display_reels, message.author.mention, str(bid))
|
slotMsg = "{}{} 226! Your bet is multiplied * 5000! {}! ".format(
|
||||||
|
display_reels, message.author.mention, str(bid))
|
||||||
elif line[0] == ":four_leaf_clover:" and line[1] == ":four_leaf_clover:" and line[2] == ":four_leaf_clover:":
|
elif line[0] == ":four_leaf_clover:" and line[1] == ":four_leaf_clover:" and line[2] == ":four_leaf_clover:":
|
||||||
bid += 1000
|
bid += 1000
|
||||||
slotMsg = "{}{} Three FLC! +1000! ".format(display_reels, message.author.mention)
|
slotMsg = "{}{} Three FLC! +1000! ".format(
|
||||||
|
display_reels, message.author.mention)
|
||||||
elif line[0] == ":cherries:" and line[1] == ":cherries:" and line[2] == ":cherries:":
|
elif line[0] == ":cherries:" and line[1] == ":cherries:" and line[2] == ":cherries:":
|
||||||
bid += 800
|
bid += 800
|
||||||
slotMsg = "{}{} Three cherries! +800! ".format(display_reels, message.author.mention)
|
slotMsg = "{}{} Three cherries! +800! ".format(
|
||||||
|
display_reels, message.author.mention)
|
||||||
elif line[0] == line[1] == line[2]:
|
elif line[0] == line[1] == line[2]:
|
||||||
bid += 500
|
bid += 500
|
||||||
slotMsg = "{}{} Three symbols! +500! ".format(display_reels, message.author.mention)
|
slotMsg = "{}{} Three symbols! +500! ".format(
|
||||||
|
display_reels, message.author.mention)
|
||||||
elif line[0] == ":two:" and line[1] == ":six:" or line[1] == ":two:" and line[2] == ":six:":
|
elif line[0] == ":two:" and line[1] == ":six:" or line[1] == ":two:" and line[2] == ":six:":
|
||||||
bid = bid * 4
|
bid = bid * 4
|
||||||
slotMsg = "{}{} 26! Your bet is multiplied * 4! {}! ".format(display_reels, message.author.mention, str(bid))
|
slotMsg = "{}{} 26! Your bet is multiplied * 4! {}! ".format(
|
||||||
|
display_reels, message.author.mention, str(bid))
|
||||||
elif line[0] == ":cherries:" and line[1] == ":cherries:" or line[1] == ":cherries:" and line[2] == ":cherries:":
|
elif line[0] == ":cherries:" and line[1] == ":cherries:" or line[1] == ":cherries:" and line[2] == ":cherries:":
|
||||||
bid = bid * 3
|
bid = bid * 3
|
||||||
slotMsg = "{}{} Two cherries! Your bet is multiplied * 3! {}! ".format(display_reels, message.author.mention, str(bid))
|
slotMsg = "{}{} Two cherries! Your bet is multiplied * 3! {}! ".format(
|
||||||
|
display_reels, message.author.mention, str(bid))
|
||||||
elif line[0] == line[1] or line[1] == line[2]:
|
elif line[0] == line[1] or line[1] == line[2]:
|
||||||
bid = bid * 2
|
bid = bid * 2
|
||||||
slotMsg = "{}{} Two symbols! Your bet is multiplied * 2! {}! ".format(display_reels, message.author.mention, str(bid))
|
slotMsg = "{}{} Two symbols! Your bet is multiplied * 2! {}! ".format(
|
||||||
|
display_reels, message.author.mention, str(bid))
|
||||||
else:
|
else:
|
||||||
slotMsg = "{}{} Nothing! Lost bet. ".format(display_reels, message.author.mention)
|
slotMsg = "{}{} Nothing! Lost bet. ".format(
|
||||||
|
display_reels, message.author.mention)
|
||||||
self.bank.withdraw_credits(message.author, bid)
|
self.bank.withdraw_credits(message.author, bid)
|
||||||
slotMsg += "\n" + " Credits left: {}".format(self.bank.get_balance(message.author))
|
slotMsg += "\n" + \
|
||||||
|
" Credits left: {}".format(
|
||||||
|
self.bank.get_balance(message.author))
|
||||||
await self.bot.send_message(message.channel, slotMsg)
|
await self.bot.send_message(message.channel, slotMsg)
|
||||||
return True
|
return True
|
||||||
self.bank.deposit_credits(message.author, bid)
|
self.bank.deposit_credits(message.author, bid)
|
||||||
slotMsg += "\n" + " Current credits: {}".format(self.bank.get_balance(message.author))
|
slotMsg += "\n" + \
|
||||||
|
" Current credits: {}".format(
|
||||||
|
self.bank.get_balance(message.author))
|
||||||
await self.bot.send_message(message.channel, slotMsg)
|
await self.bot.send_message(message.channel, slotMsg)
|
||||||
|
|
||||||
@commands.group(pass_context=True, no_pm=True)
|
@commands.group(pass_context=True, no_pm=True)
|
||||||
@ -504,6 +558,7 @@ 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)
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
@economyset.command(pass_context=True)
|
@economyset.command(pass_context=True)
|
||||||
async def registercredits(self, ctx, credits : int):
|
async def registercredits(self, ctx, credits : int):
|
||||||
"""Credits given on registering an account"""
|
"""Credits given on registering an account"""
|
||||||
@ -516,6 +571,11 @@ class Economy:
|
|||||||
|
|
||||||
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
|
||||||
|
=======
|
||||||
|
# What would I ever do without stackoverflow?
|
||||||
|
def display_time(self, seconds, granularity=2):
|
||||||
|
intervals = ( # Source: http://stackoverflow.com/a/24542445
|
||||||
|
>>>>>>> cb472f9... Some PEP8 stuff
|
||||||
('weeks', 604800), # 60 * 60 * 24 * 7
|
('weeks', 604800), # 60 * 60 * 24 * 7
|
||||||
('days', 86400), # 60 * 60 * 24
|
('days', 86400), # 60 * 60 * 24
|
||||||
('hours', 3600), # 60 * 60
|
('hours', 3600), # 60 * 60
|
||||||
@ -559,9 +619,12 @@ def setup(bot):
|
|||||||
check_folders()
|
check_folders()
|
||||||
check_files()
|
check_files()
|
||||||
logger = logging.getLogger("red.economy")
|
logger = logging.getLogger("red.economy")
|
||||||
if logger.level == 0: # Prevents the logger from being loaded again in case of module reload
|
if logger.level == 0:
|
||||||
|
# Prevents the logger from being loaded again in case of module reload
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
handler = logging.FileHandler(filename='data/economy/economy.log', encoding='utf-8', mode='a')
|
handler = logging.FileHandler(
|
||||||
handler.setFormatter(logging.Formatter('%(asctime)s %(message)s', datefmt="[%d/%m/%Y %H:%M]"))
|
filename='data/economy/economy.log', encoding='utf-8', mode='a')
|
||||||
|
handler.setFormatter(logging.Formatter(
|
||||||
|
'%(asctime)s %(message)s', datefmt="[%d/%m/%Y %H:%M]"))
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
bot.add_cog(Economy(bot))
|
bot.add_cog(Economy(bot))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user