How to use the cogs.utils.dataIO.fileIO 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 irdumbs / Dumb-Cogs / adventure / adventure.py View on Github external
except:
                channels = []
        for cid in channels:
            for pid in players:
                if pid in self.players[server.id][cid]:
                    del self.players[server.id][cid][pid]

        # game_loops
        del self.game_loops[server.id][team]
        # teams
        del self.teams[server.id]["TEAMS"][team]
        for pid in players:
            if pid in self.teams[server.id]["MEMBERS"]: # it better be
                if team in self.teams[server.id]["MEMBERS"][pid]: # it better be
                    self.teams[server.id]["MEMBERS"][pid].remove(team)
        fileIO('data/adventure/teams.json', 'save', self.teams)
        # saves
        del self.saves[server.id][team]
        # path
        shutil.rmtree('{}/{}/{}'.format(bp, server.id, team))
github TrustyJAID / Trusty-cogs-archive / trustymodlog / trustymodlog.py View on Github external
async def on_member_update(self, before, after):
        server = before.server
        db = fileIO(self.direct, "load")
        if not server.id in db:
            return
        if db[server.id]['toggleuser'] and db[server.id]['toggleroles'] == False:
            return
        channel = db[server.id]["Channel"]
        time = datetime.datetime.now()
        fmt = '%d/%m/%y %H:%M:%S'
        if not before.nick == after.nick:
            embed = discord.Embed(description="User Name Changed", colour=discord.Colour.gold())
            embed.add_field(name=before + "|" + before.id, value=before.nick + " to " + after.nick)
            embed.add_field(name="Time", value=time.strftime(fmt))
            await self.bot.send_message(server.get_channel(channel), embed=embed)
        if not before.roles == after.roles:
            embed = discord.Embed(description="User Role Changed for " + str(before) + " | " + str(before.id), colour=discord.Colour.gold())
            embed.add_field(name="Roles before", value=" | ".join([r.name for r in before.roles if r.name != "@everyone"]))
            embed.add_field(name="Roles After", value=" | ".join([r.name for r in after.roles if r.name != "@everyone"]))
github TrustyJAID / Trusty-cogs-archive / trustymodlog / trustymodlog.py View on Github external
def check_file():
    f = 'data/modlogset/settings.json'
    if not fileIO(f, 'check'):
        print('Creating default settings.json...')
        fileIO(f, 'save', {})
github Cog-Creators / Red-DiscordBot / cogs / quote.py View on Github external
def check_files():
    f = "data/quote/quote.json"
    if not fileIO(f, "check"):
        print("Creating empty quote.json...")
        fileIO(f, "save", {})
github irdumbs / Dumb-Cogs / adventure / adventure.py View on Github external
raise MissingFile(base_path + file + " is missing.")

    files = {'teams.json' : {}, 'settings.json' : {}}
    for file, default in files.items():
        if not os.path.isfile(base_path + file):
            print("Creating default adventure {}...".format(file))
            fileIO(base_path + file, "save", default)
        else:  # consistency check
            current = fileIO(base_path + file, "load")
            if current.keys() != default.keys():
                for key in default.keys():
                    if key not in current.keys():
                        current[key] = default[key]
                        print(
                            "Adding " + str(key) + " field to adventure {}".format(file))
                fileIO(base_path + file, "save", current)
github Canule / Mash-Cogs / rss / rss.py View on Github external
def save_feeds(self):
        fileIO("data/RSS/feeds.json", "save", self.feeds)
github Canule / Mash-Cogs / rss / rss.py View on Github external
def __init__(self):
        self.check_folders()
        # {server:{channel:{name:,url:,last_scraped:,template:}}}
        self.feeds = fileIO("data/RSS/feeds.json", "load")
github Canule / Mash-Cogs / rss / rss.py View on Github external
def check_files(self):
        f = "data/RSS/feeds.json"
        if not fileIO(f, "check"):
            print("Creating empty feeds.json...")
            fileIO(f, "save", {})