How to use the cogs.utils.dataIO.dataIO.is_valid_json function in Cogs

To help you get started, we’ve selected a few Cogs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Cog-Creators / Red-DiscordBot / cogs / audio.py View on Github external
def _playlist_exists_global(self, name):
        f = "data/audio/playlists"
        f = os.path.join(f, name + ".txt")
        log.debug('checking for {}'.format(f))

        return dataIO.is_valid_json(f)
github Kowlin / refactored-cogs / antilink / antilink.py View on Github external
def check_file():
    f = 'data/antilink/settings.json'
    if dataIO.is_valid_json(f) is False:
        dataIO.save_json(f, {})
github Kowlin / refactored-cogs / githubcards / githubcards.py View on Github external
def check_file():
    f = 'data/githubcards/settings.json'
    if dataIO.is_valid_json(f) is False:
        dataIO.save_json(f, {})
github fixator10 / Fixator10-Cogs / selfrole / selfrole.py View on Github external
def check_files():
    system = {}
    f = "data/selfrole/config.json"
    if not dataIO.is_valid_json(f):
        dataIO.save_json(f, system)
github devakira / NanoBot / cogs / audio.py View on Github external
def _playlist_exists_global(self, name):
        f = "data/audio/playlists"
        f = os.path.join(f, name + ".txt")
        log.debug('checking for {}'.format(f))

        return dataIO.is_valid_json(f)
github Twentysix26 / 26-Cogs / trigger / trigger.py View on Github external
def check_files():
    f = "data/trigger/triggers.json"
    if not dataIO.is_valid_json(f):
        print("Creating empty triggers.json...")
        dataIO.save_json(f, [])
github aikaterna / aikaterna-cogs / picwelcome / picwelcome.py View on Github external
def check_files():
    if not dataIO.is_valid_json('data/picwelcome/settings.json'):
        defaults = {}
        dataIO.save_json('data/picwelcome/settings.json', defaults)
github devakira / NanoBot / cogs / utils / settings.py View on Github external
self.path = path
        self.check_folders()
        self.default_settings = {
            "TOKEN": None, #bot token
            "BOTSDISCORDPW_TOKEN": None, # https://bots.discord.pw token
            "DISCORDBOTSORG_TOKEN": None, # https://discordbots.org token
            "OWNER": None, #owner id
            "DEVELOPER": None, #dev id
            "PREFIXES": [], #server prefix
			"DEV_MODE": "0", #dev mode
            "default": {"ADMIN_ROLE": "NanoBot Admin",
                        "MOD_ROLE": "NanoBot Mod"}
			}
        self._memory_only = False

        if not dataIO.is_valid_json(self.path):
            self.bot_settings = deepcopy(self.default_settings)
            self.save_settings()
        else:
            current = dataIO.load_json(self.path)
            if current.keys() != self.default_settings.keys():
                for key in self.default_settings.keys():
                    if key not in current.keys():
                        current[key] = self.default_settings[key]
                        print("Adding " + str(key) +
                              " field to settings.json")
                dataIO.save_json(self.path, current)
            self.bot_settings = dataIO.load_json(self.path)

        self.save_settings()