From bb3721478fb29aee0f7e745792db773be1882c32 Mon Sep 17 00:00:00 2001 From: Myned Date: Sun, 24 Sep 2017 15:13:36 -0400 Subject: [PATCH] "Added prefix to config and fixed initial startup" --- src/main/cogs/booru.py | 6 +++--- src/main/run.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/cogs/booru.py b/src/main/cogs/booru.py index fb335d2..a22f730 100644 --- a/src/main/cogs/booru.py +++ b/src/main/cogs/booru.py @@ -395,7 +395,7 @@ class MsG: @commands.is_owner() async def __clear_global_blacklist(self, ctx): global global_blacklist - global_blacklist = [] + del global_blacklist with open('global_blacklist.json', 'w') as outfile: json.dump(global_blacklist, outfile, indent=4, sort_keys=True) await ctx.send('✅ **Global blacklist cleared.**', delete_after=5) @@ -408,7 +408,7 @@ class MsG: else: guild = ctx.message.channel channel = ctx.message.channel - guild_blacklist.get(str(guild.id), {})[str(channel.id)] = [] + del guild_blacklist.get(str(guild.id), {})[str(channel.id)] with open('guild_blacklist.json', 'w') as outfile: json.dump(guild_blacklist, outfile, indent=4, sort_keys=True) await ctx.send('✅ <#' + str(channel.id) + '> **blacklist cleared.**', delete_after=5) @@ -416,7 +416,7 @@ class MsG: async def __clear_user_blacklist(self, ctx): global user_blacklist user = ctx.message.author - user_blacklist[str(user.id)] = [] + del user_blacklist[str(user.id)] with open('user_blacklist.json', 'w') as outfile: json.dump(user_blacklist, outfile, indent=4, sort_keys=True) await ctx.send('✅ ' + user.mention + '**\'s blacklist cleared.**', delete_after=5) diff --git a/src/main/run.py b/src/main/run.py index 6c1d7ab..57fec71 100644 --- a/src/main/run.py +++ b/src/main/run.py @@ -6,7 +6,7 @@ try: print('\"config.json\" loaded.') except FileNotFoundError: with open('config.json', 'w') as outfile: - json.dump({'client_id': 0, 'owner_id': 0, 'permissions': 0, 'shutdown_channel': 0, 'startup_channel': 0, 'token': 'str'}, outfile, indent=4, sort_keys=True) + json.dump({'client_id': 0, 'owner_id': 0, 'permissions': 388160, 'prefix': ',', '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 @@ -18,12 +18,13 @@ 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') +bot = commands.Bot(command_prefix=commands.when_mentioned_or(config['prefix']), description='Experimental booru bot') # Send and print ready message to #testing and console after logon @bot.event async def on_ready(): - await bot.get_channel(config['startup_channel']).send('Hello how are? **Have day.** 🌈\n[STARTUP-INFO]') + if isinstance(bot.get_channel(config['startup_channel']), discord.TextChannel): + await bot.get_channel(config['startup_channel']).send('Hello how are? **Have day.** 🌈\n[STARTUP-INFO]') print('Connected.') print('Username: ' + bot.user.name) print('-------') @@ -34,8 +35,7 @@ async def on_ready(): @commands.is_owner() async def die(ctx): try: - await ctx.send('Am go bye. **Have night.** 💤') - # await bot.get_channel(config['shutdown_channel']).send('[SHUTDOWN-INFO]') + await bot.get_channel(config['shutdown_channel']).send('Am go bye. **Have night.** 💤\n[SHUTDOWN-INFO]') await bot.close() print('-------') print('Closed.')