FileIO to DataIO conversion (#410)

This commit is contained in:
Twentysix
2016-10-10 03:40:09 +02:00
committed by GitHub
parent 7dc597a272
commit 7a3c963009
8 changed files with 110 additions and 90 deletions

View File

@@ -2,7 +2,7 @@ import discord
from discord.ext import commands
from cogs.utils import checks
from __main__ import set_cog, send_cmd_help, settings
from .utils.dataIO import fileIO
from .utils.dataIO import dataIO
from .utils.chat_formatting import pagify
import importlib
@@ -46,7 +46,8 @@ class Owner:
def __init__(self, bot):
self.bot = bot
self.setowner_lock = False
self.disabled_commands = fileIO("data/red/disabled_commands.json", "load")
self.file_path = "data/red/disabled_commands.json"
self.disabled_commands = dataIO.load_json(self.file_path)
self.session = aiohttp.ClientSession(loop=self.bot.loop)
def __unload(self):
@@ -425,7 +426,7 @@ class Owner:
comm_obj.enabled = False
comm_obj.hidden = True
self.disabled_commands.append(command)
fileIO("data/red/disabled_commands.json", "save", self.disabled_commands)
dataIO.save_json(self.file_path, self.disabled_commands)
await self.bot.say("Command has been disabled.")
@command_disabler.command()
@@ -433,7 +434,7 @@ class Owner:
"""Enables commands/subcommands"""
if command in self.disabled_commands:
self.disabled_commands.remove(command)
fileIO("data/red/disabled_commands.json", "save", self.disabled_commands)
dataIO.save_json(self.file_path, self.disabled_commands)
await self.bot.say("Command enabled.")
else:
await self.bot.say("That command is not disabled.")
@@ -672,10 +673,12 @@ class Owner:
return 'Last updated: ``{}``\nCommit: ``{}``\nHash: ``{}``'.format(
*version)
def check_files():
if not os.path.isfile("data/red/disabled_commands.json"):
print("Creating empty disabled_commands.json...")
fileIO("data/red/disabled_commands.json", "save", [])
dataIO.save_json("data/red/disabled_commands.json", [])
def setup(bot):
check_files()