mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
Guard module-level creation of Config objects (#2449)
Signed-off-by: Toby Harradine <tobyharradine@gmail.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import datetime
|
||||
import os
|
||||
from typing import Union, List, Optional
|
||||
|
||||
import discord
|
||||
@@ -42,6 +41,17 @@ _DEFAULT_MEMBER = {"name": "", "balance": 0, "created_at": 0}
|
||||
|
||||
_DEFAULT_USER = _DEFAULT_MEMBER
|
||||
|
||||
_conf: Config = None
|
||||
|
||||
|
||||
def _init():
|
||||
global _conf
|
||||
_conf = Config.get_conf(None, 384734293238749, cog_name="Bank", force_registration=True)
|
||||
_conf.register_global(**_DEFAULT_GLOBAL)
|
||||
_conf.register_guild(**_DEFAULT_GUILD)
|
||||
_conf.register_member(**_DEFAULT_MEMBER)
|
||||
_conf.register_user(**_DEFAULT_USER)
|
||||
|
||||
|
||||
class Account:
|
||||
"""A single account.
|
||||
@@ -54,18 +64,6 @@ class Account:
|
||||
self.created_at = created_at
|
||||
|
||||
|
||||
def _register_defaults():
|
||||
_conf.register_global(**_DEFAULT_GLOBAL)
|
||||
_conf.register_guild(**_DEFAULT_GUILD)
|
||||
_conf.register_member(**_DEFAULT_MEMBER)
|
||||
_conf.register_user(**_DEFAULT_USER)
|
||||
|
||||
|
||||
if not os.environ.get("BUILDING_DOCS"):
|
||||
_conf = Config.get_conf(None, 384734293238749, cog_name="Bank", force_registration=True)
|
||||
_register_defaults()
|
||||
|
||||
|
||||
def _encoded_current_time() -> int:
|
||||
"""Get the current UTC time as a timestamp.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user