Ensure database exists before loading it
This commit is contained in:
parent
d950c458ef
commit
e239194636
3
bot.py
3
bot.py
|
@ -106,8 +106,7 @@ if __name__ == '__main__':
|
|||
# Setup our bot vars, db and cache
|
||||
bot.db = utils.DB()
|
||||
bot.cache = utils.Cache(bot.db)
|
||||
# Start our startup tasks
|
||||
bot.loop.create_task(bot.db.setup())
|
||||
# Start our startup task (cache sets up the database, so just this)
|
||||
bot.loop.create_task(bot.cache.setup())
|
||||
for e in utils.extensions:
|
||||
bot.load_extension(e)
|
||||
|
|
|
@ -17,6 +17,9 @@ class Cache:
|
|||
self.restrictions = defaultdict(dict)
|
||||
|
||||
async def setup(self):
|
||||
# Make sure db is setup first
|
||||
await self.db.setup()
|
||||
|
||||
await self.load_prefixes()
|
||||
await self.load_custom_permissions()
|
||||
await self.load_restrictions()
|
||||
|
@ -34,8 +37,8 @@ WHERE
|
|||
"""
|
||||
rows = await self.db.fetch(query)
|
||||
for row in rows:
|
||||
self.ignored[row['guild']]['members'] = row['ignored_members']
|
||||
self.ignored[row['guild']]['channels'] = row['ignored_channels']
|
||||
self.ignored[row['id']]['members'] = row['ignored_members']
|
||||
self.ignored[row['id']]['channels'] = row['ignored_channels']
|
||||
|
||||
async def load_prefixes(self):
|
||||
query = """
|
||||
|
|
Loading…
Reference in a new issue