[V3 Config] Record custom group information using cog_add event (#2550)

* Do things differently

* Uncomment critical lines

* Reduce, reuse, recycle

* Check groups on all new config objects after a cog loads

* I don't know why this is failing now or why we need the global keyword

* gotta fix this too
This commit is contained in:
Will
2019-04-09 22:02:50 -04:00
committed by GitHub
parent e347ffa336
commit ba19179e4f
3 changed files with 25 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ from pkg_resources import DistributionNotFound
from .. import __version__ as red_version, version_info as red_version_info, VersionInfo
from . import commands
from .config import get_latest_confs
from .data_manager import storage_type
from .utils.chat_formatting import inline, bordered, format_perms_list, humanize_timedelta
from .utils import fuzzy_command_search, format_fuzzy_results
@@ -305,6 +306,14 @@ def init_events(bot, cli_flags):
if command_obj is not None:
command_obj.enable_in(guild)
@bot.event
async def on_cog_add(cog: commands.Cog):
confs = get_latest_confs()
for c in confs:
uuid = c.unique_identifier
group_data = c.custom_groups
await bot.db.custom("CUSTOM_GROUPS", c.cog_name, uuid).set(group_data)
def _get_startup_screen_specs():
"""Get specs for displaying the startup screen on stdout.