# Path: meowth/core/errors.py
# class LocationNotSet(CommandError):
#     'Exception raised checks.location_set fails'
#     pass


from discord.ext import commands
from .errors import LocationNotSet

async def check_cog_enabled(ctx, default=True):
    enabled = await ctx.cog_enabled()
    return enabled if enabled is not None else default

def cog_enabled():
    return commands.check(check_cog_enabled)

async def check_is_report_channel(ctx):
    table = ctx.bot.dbi.table('report_channels')
    query = table.query.where(channelid=ctx.channel.id)
    data = await query.get()
    if data:
        return True
    return False

def is_report_channel():
    return commands.check(check_is_report_channel)

async def check_location_set(ctx):
    table = ctx.bot.dbi.table('report_channels')
    query = table.query.where(channelid=ctx.channel.id)
    data = await query.get()
    if data:
        data = dict(data[0])
    else:
        raise LocationNotSet
    values = [data.get('lat'), data.get('lon'), data.get('radius')]
    for x in values:
        if x is None:

# Path: meowth/core/errors.py
# class LocationNotSet(CommandError):
#     'Exception raised checks.location_set fails'
#     pass


# Path: meowth/core/checks.py
from discord.ext import commands
from .errors import LocationNotSet


async def check_cog_enabled(ctx, default=True):
    enabled = await ctx.cog_enabled()
    return enabled if enabled is not None else default

def cog_enabled():
    return commands.check(check_cog_enabled)

async def check_is_report_channel(ctx):
    table = ctx.bot.dbi.table('report_channels')
    query = table.query.where(channelid=ctx.channel.id)
    data = await query.get()
    if data:
        return True
    return False

def is_report_channel():
    return commands.check(check_is_report_channel)

async def check_location_set(ctx):
    table = ctx.bot.dbi.table('report_channels')
    query = table.query.where(channelid=ctx.channel.id)
    data = await query.get()
    if data:
        data = dict(data[0])
    else:
        raise LocationNotSet
    values = [data.get('lat'), data.get('lon'), data.get('radius')]
    for x in values:
        if x is None:

            raise LocationNotSet