1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 13:02:38 +00:00

Fixed config file creation

This commit is contained in:
Myned 2017-09-24 14:09:02 -04:00
parent 52648613bf
commit 3d02095687
2 changed files with 24 additions and 22 deletions

View file

@ -1,22 +1,12 @@
import asyncio
import discord
import json
import requests
import traceback
from discord import reaction
from discord.ext import commands
from discord.ext.commands import errors
from misc import checks
from misc import exceptions as exc
from utils import formatter, scraper
try:
with open('global_blacklist.json') as infile:
global_blacklist = json.load(infile)
print('\"global_blacklist.json\" loaded.')
except FileNotFoundError:
print('Blacklist file not found: \"global_blacklist.json\" created.')
with open('global_blacklist.json', 'w+') as iofile:
print('Blacklist file not found: \"global_blacklist.json\" created.')
json.dump([], iofile, indent=4, sort_keys=True)
iofile.seek(0)
global_blacklist = json.load(iofile)
@ -25,8 +15,8 @@ try:
guild_blacklist = json.load(infile)
print('\"guild_blacklist.json\" loaded.')
except FileNotFoundError:
print('Blacklist file not found: \"guild_blacklist.json\" created.')
with open('guild_blacklist.json', 'w+') as iofile:
print('Blacklist file not found: \"guild_blacklist.json\" created.')
json.dump({}, iofile, indent=4, sort_keys=True)
iofile.seek(0)
guild_blacklist = json.load(iofile)
@ -35,12 +25,23 @@ try:
user_blacklist = json.load(infile)
print('\"user_blacklist.json\" loaded.')
except FileNotFoundError:
print('Blacklist file not found: \"user_blacklist.json\" created.')
with open('user_blacklist.json', 'w+') as iofile:
print('Blacklist file not found: \"user_blacklist.json\" created.')
json.dump({}, iofile, indent=4, sort_keys=True)
iofile.seek(0)
user_blacklist = json.load(iofile)
import asyncio
import discord
import requests
import traceback
from discord import reaction
from discord.ext import commands
from discord.ext.commands import errors
from misc import checks
from misc import exceptions as exc
from utils import formatter, scraper
last_command = {}
class MsG:

View file

@ -1,12 +1,4 @@
import asyncio
import discord
import json
import traceback
from discord import utils
from discord.ext import commands
from cogs import booru, info, tools
from misc import checks
from misc import exceptions as exc
try:
with open('config.json') as infile:
@ -14,9 +6,18 @@ try:
print('\"config.json\" loaded.')
except FileNotFoundError:
with open('config.json', 'w') as outfile:
json.dump({'client_id': 'int', 'owner_id': 'int', 'permissions': 'int', 'shutdown_channel': 'int', 'startup_channel': 'int', 'token': 'str'}, outfile, indent=4, sort_keys=True)
json.dump({'client_id': 0, 'owner_id': 0, 'permissions': 0, 'shutdown_channel': 0, 'startup_channel': 0, 'token': 'str'}, outfile, indent=4, sort_keys=True)
raise FileNotFoundError('Config file not found: \"config.json\" created with abstract values. Restart \"run.py\" with correct values.')
import asyncio
import discord
import traceback
from discord import utils
from discord.ext import commands
from cogs import booru, info, tools
from misc import checks
from misc import exceptions as exc
bot = commands.Bot(command_prefix=commands.when_mentioned_or(','), description='Experimental booru bot')
# Send and print ready message to #testing and console after logon