[Core] Replaced JsonDB with Config (#770)

This commit is contained in:
Will
2017-05-27 22:28:59 -04:00
committed by Twentysix
parent a8745297dc
commit 3988fbbc09
23 changed files with 1298 additions and 380 deletions

View File

@@ -1,3 +1,6 @@
from discord.ext import commands
def init_global_checks(bot):
@bot.check
@@ -5,20 +8,19 @@ def init_global_checks(bot):
if await bot.is_owner(ctx.author):
return True
if bot.db.get_global("whitelist", []):
return ctx.author.id in bot.db.get_global("whitelist", [])
if bot.db.whitelist():
return ctx.author.id in bot.db.whitelist()
return ctx.author.id not in bot.db.get_global("blacklist", [])
return ctx.author.id not in bot.db.blacklist()
@bot.check
async def local_perms(ctx):
async def local_perms(ctx: commands.Context):
if await bot.is_owner(ctx.author):
return True
elif ctx.message.guild is None:
return True
guild_perms = bot.db.get_all(ctx.guild, {})
local_blacklist = guild_perms.get("blacklist", [])
local_whitelist = guild_perms.get("whitelist", [])
local_blacklist = bot.db.guild(ctx.guild).blacklist()
local_whitelist = bot.db.guild(ctx.guild).whitelist()
if local_whitelist:
return ctx.author.id in local_whitelist