async def predicate(ctx: Context) -> bool: async with ctx.bot.pool.acquire() as conn: alliance = await conn.fetchval( 'SELECT alliance FROM guild WHERE "id"=$1', ctx.character_data["guild"] ) owned_city = await conn.fetchval( 'SELECT name FROM city WHERE "owner"=$1', alliance ) if not owned_city: raise NoCityOwned() ctx.city = owned_city return True
async def predicate(ctx: Context) -> bool: async with ctx.bot.pool.acquire() as conn: if not hasattr(ctx, "character_data"): ctx.character_data = await conn.fetchrow( 'SELECT * FROM profile WHERE "user"=$1;', ctx.author.id) alliance = await conn.fetchval( 'SELECT alliance FROM guild WHERE "id"=$1', ctx.character_data["guild"]) owned_city = await conn.fetchval( 'SELECT name FROM city WHERE "owner"=$1', alliance) if not owned_city: raise NoCityOwned() ctx.city = owned_city return True