mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 10:17:59 -05:00
[Config] Group.__call__() has same behaviour as Group.all() (#2018)
* Make calling groups useful This makes config.Group.__call__ effectively an alias for Group.all(), with the added bonus of becoming a context manager. get_raw has been updated as well to reflect the new behaviour of __call__. * Fix unintended side-effects of new behaviour * Add tests * Add test for get_raw mixing in defaults * Another cleanup for relying on old behaviour internally * Fix bank relying on old behaviour * Reformat
This commit is contained in:
@@ -400,19 +400,18 @@ async def get_account(member: Union[discord.Member, discord.User]) -> Account:
|
||||
|
||||
"""
|
||||
if await is_global():
|
||||
acc_data = (await _conf.user(member)()).copy()
|
||||
default = _DEFAULT_USER.copy()
|
||||
all_accounts = await _conf.all_users()
|
||||
else:
|
||||
acc_data = (await _conf.member(member)()).copy()
|
||||
default = _DEFAULT_MEMBER.copy()
|
||||
all_accounts = await _conf.all_members(member.guild)
|
||||
|
||||
if acc_data == {}:
|
||||
acc_data = default
|
||||
acc_data["name"] = member.display_name
|
||||
if member.id not in all_accounts:
|
||||
acc_data = {"name": member.display_name, "created_at": _DEFAULT_MEMBER["created_at"]}
|
||||
try:
|
||||
acc_data["balance"] = await get_default_balance(member.guild)
|
||||
except AttributeError:
|
||||
acc_data["balance"] = await get_default_balance()
|
||||
else:
|
||||
acc_data = all_accounts[member.id]
|
||||
|
||||
acc_data["created_at"] = _decode_time(acc_data["created_at"])
|
||||
return Account(**acc_data)
|
||||
|
||||
Reference in New Issue
Block a user