def update_config_from_1_to_2(self, old_config): """ Updates the configuration from version 1 (indicator: contains '_prefix') to version 2 :param old_config: the old config dict """ logging.info("Update Custom CMD config from version 1 to version 2") new_config = self.default_config() new_config['prefix'] = old_config['_prefix'] logging.info(f"Converting {len(old_config) - 1} custom commands...") new_cmds = {} for cmd in old_config.keys(): if cmd == '_prefix': continue cmd_name = cmd.lower() if cmd_name in new_cmds: new_cmds[cmd_name]['texts'].append(old_config[cmd]) else: new_cmds[cmd_name] = Cmd(cmd_name, 0, [old_config[cmd]]).serialize() Storage.set(self, new_cmds) # Config.save(self) Storage.save(self) logging.info("Converting finished.")
def save(self): """Saves the commands to the storage and the plugin config""" cmd_dict = {} for k in self.commands: cmd_dict[k] = self.commands[k].serialize() Storage.set(self, cmd_dict) Storage.save(self) Config.save(self)
def save(self): """Saves the current ignorelist to json""" full_list = [] full_list.extend(self.users) full_list.extend(self.cmds) full_list.extend(self.user_cmds) jsondata = [] for el in full_list: jsondata.append(el.serialize()) Storage.set(self, jsondata) Storage.save(self)