How to use the playsound.utils.dataIO.dataIO.save_json function in playsound

To help you get started, we’ve selected a few playsound 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 tmercswims / tmerc-cogs / playsound / playsound.py View on Github external
def check_files():
    f = "data/playsound/settings.json"
    if not dataIO.is_valid_json(f):
        print("Creating data/playsound/settings.json...")
        dataIO.save_json(f, {})
github tmercswims / tmerc-cogs / playsound / playsound.py View on Github external
soundname + ".*"))
        if len(f) < 1:
            await self.bot.say(cf.error(
                "Sound file not found. Try `{}allsounds` for a list.".format(
                    ctx.prefix)))
            return
        elif len(f) > 1:
            await self.bot.say(cf.error(
                "There are {} sound files with the same name, but different"
                " extensions, and I can't deal with it. Please make filenames"
                " (excluding extensions) unique.".format(len(f))))
            return

        if soundname not in self.settings[server.id]:
            self.settings[server.id][soundname] = {"volume": default_volume}
            dataIO.save_json(self.settings_path, self.settings)

        if percent is None:
            await self.bot.reply("Volume for {} is {}.".format(
                soundname, self.settings[server.id][soundname]["volume"]))
            return

        self.settings[server.id][soundname]["volume"] = percent
        dataIO.save_json(self.settings_path, self.settings)

        await self.bot.reply("Volume for {} set to {}.".format(soundname,
                                                               percent))