def reload(self, opts: Dict = None, read_only: bool = None): if opts is None: opts = self._opts if read_only is None: read_only = self._read_only rocks_opts = Options(create_if_missing=True) for key, value in opts.items(): setattr(rocks_opts, key, value) if hasattr(self, '_db'): self.close() self._db = DB(self._path, rocks_opts, read_only=read_only)
import os import discord from rocksdb import DB, Options from characterhandler import CharacterHandler from commandhandler import CommandHandler from conditionhandler import ConditionHandler from inspirehandler import InspireHandler from kv import KV from rollhandler import RollHandler if __name__ == '__main__': client = discord.Client() rocks_db_location = os.getenv('ROCKS_DB_LOCATION', 'anathema.db') kv = KV(DB(rocks_db_location, Options(create_if_missing=True))) handlers = [ RollHandler(kv), InspireHandler(), CharacterHandler(kv), ConditionHandler() ] command_handler = CommandHandler(kv, handlers.copy()) handlers.append(command_handler) @client.event async def on_ready(): """Handles bot start"""