async def predicate(ctx: Context) -> bool: if not hasattr(ctx, "character_data"): ctx.character_data = await ctx.bot.cache.get_profile(ctx.author.id) if ( check := ctx.bot.in_class_line(ctx.character_data["class"], class_) ) and class_ == "Ranger": ctx.pet_data = await ctx.bot.pool.fetchrow( 'SELECT * FROM pets WHERE "user"=$1;', ctx.author.id )
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
async def predicate(ctx: Context) -> bool: ctx.character_data = await ctx.bot.pool.fetchrow( 'SELECT * FROM profile WHERE "user"=$1;', ctx.author.id ) if ctx.character_data: return True raise NoCharacter()
async def predicate(ctx: Context) -> bool: if not hasattr(ctx, "character_data"): ctx.character_data = await ctx.bot.cache.get_profile(ctx.author.id) classes = [ c for i in ctx.character_data["class"] if (c := class_from_string(i)) ]
async def predicate(ctx: Context) -> bool: ctx.character_data = await ctx.bot.pool.fetchrow( 'SELECT * FROM profile WHERE "user"=$1;', ctx.author.id ) if ctx.character_data["guildrank"] != "Leader": return True raise NeedsNoGuildLeader()
def invoke(self, message): command = message.split(" ")[0] command = self.commands.get(command) if not command: raise NotFound() ctx = Context(message=message, command=command) ctx.command.invoke(ctx)
async def predicate(ctx: Context) -> bool: response = await ctx.bot.redis.execute_command( "GET", f"helpme:{ctx.guild.id}") if not response: raise NoOpenHelpRequest() ctx.helpme = response.decode() return True
async def predicate(ctx: Context) -> bool: if not hasattr(ctx, "character_data"): ctx.character_data = await ctx.bot.cache.get_profile(ctx.author.id) if (ctx.character_data["guildrank"] == "Leader" or ctx.character_data["guildrank"] == "Officer"): return True raise NoGuildPermissions()
async def predicate(ctx: Context) -> bool: if not hasattr(ctx, "character_data"): ctx.character_data = await ctx.bot.pool.fetchrow( 'SELECT * FROM profile WHERE "user"=$1;', ctx.author.id) if ctx.character_data["god"]: return True raise NeedsGod()
async def predicate(ctx: Context) -> bool: if not hasattr(ctx, "character_data"): ctx.character_data = await ctx.bot.pool.fetchrow( 'SELECT * FROM profile WHERE "user"=$1;', ctx.author.id) if ctx.character_data["guildrank"] == "Leader": return True raise NoGuildPermissions()
async def predicate(ctx: Context) -> bool: if not hasattr(ctx, "character_data"): ctx.character_data = await ctx.bot.pool.fetchrow( 'SELECT * FROM profile WHERE "user"=$1;', ctx.author.id) classes = [ c for i in ctx.character_data["class"] if (c := class_from_string(i)) ]
async def predicate(ctx: Context) -> bool: async with ctx.bot.pool.acquire() as conn: ret = await conn.fetchval( 'SELECT class FROM profile WHERE "user"=$1;', ctx.author.id ) if (check := ctx.bot.in_class_line(ret, class_)) and class_ == "Ranger": ctx.pet_data = await conn.fetchrow( 'SELECT * FROM pets WHERE "user"=$1;', ctx.author.id )
async def predicate(ctx: Context) -> bool: if not ctx.pet_data: raise PetGone() diff = ( (now := datetime.datetime.now(pytz.utc)) - ctx.pet_data["last_update"] ) // datetime.timedelta(hours=2) if diff >= 1: # Pets loose 2 food, 4 drinks, 1 joy and 1 love async with ctx.bot.pool.acquire() as conn: data = await conn.fetchrow( 'UPDATE pets SET "food"="food"-$1, "drink"="drink"-$2, "joy"=CASE' ' WHEN "joy"-$3>=0 THEN "joy"-$3 ELSE 0 END, "love"=CASE WHEN' ' "love"-$4>=0 THEN "love"-$4 ELSE 0 END, "last_update"=$5 WHERE' ' "user"=$6 RETURNING *;', diff * 2, diff * 4, diff, diff, now, ctx.author.id, ) ctx.pet_data = data classes = ctx.character_data["class"] for evolve in ["Caretaker"] + ctx.bot.get_class_evolves()["Ranger"]: if evolve in classes: idx = classes.index(evolve) break if data["food"] < 0 or data["drink"] < 0: classes[idx] = "No Class" await conn.execute( 'DELETE FROM pets WHERE "user"=$1;', ctx.author.id ) await conn.execute( 'UPDATE profile SET "class"=$1 WHERE "user"=$2;', classes, ctx.author.id, ) await ctx.bot.cache.update_profile_cols_abs( ctx.author.id, class_=classes ) raise PetDied() elif data["love"] < 75 and random.randint(0, 99) > data["love"]: classes[idx] = "No Class" await conn.execute( 'DELETE FROM pets WHERE "user"=$1;', ctx.author.id ) await conn.execute( 'UPDATE profile SET "class"=$1 WHERE "user"=$2;', classes, ctx.author.id, ) await ctx.bot.cache.update_profile_cols_abs( ctx.author.id, class_=classes ) raise PetRanAway() return True
def __init__(self, parent): self.title = "title" self.path = "/home/nathan/Documents/workspace/rox projects" self.render = None context = Context(parent) project = MoreTex (None, context) context.root = project project.append (Init, context) firstText = Text (project, context) firstText.breakType = "nothing" project.quickAppend (firstText) project.append (Math, context) hep = MoreTex (project, context) hep.append (Text, context) project.texFiles.append (hep) self.root = project self.ratio = (9, 12)
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 ctx.bot.cache.get_profile( ctx.author.id, conn=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 owned_city: raise CityOwned() 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) leading_guild = await conn.fetchval( 'SELECT alliance FROM guild WHERE "id"=$1;', ctx.character_data["guild"]) if (leading_guild == ctx.character_data["guild"] and ctx.character_data["guildrank"] == "Leader"): return True raise NoAlliancePermissions()
async def predicate(ctx: Context) -> bool: ctx.adventure_data = await ctx.bot.get_adventure(ctx.author) if ctx.adventure_data: return True raise NeedsAdventure()
async def predicate(ctx: Context) -> bool: if not hasattr(ctx, "character_data"): ctx.character_data = await ctx.bot.cache.get_profile(ctx.author.id) if ctx.character_data["god"]: return True raise NeedsGod()
async def predicate(ctx: Context) -> bool: if not hasattr(ctx, "character_data"): ctx.character_data = await ctx.bot.cache.get_profile(ctx.author.id) if ctx.character_data["guildrank"] != "Leader": return True raise NeedsNoGuildLeader()
async def predicate(ctx: Context) -> bool: ctx.character_data = await ctx.bot.cache.get_profile(ctx.author.id) if ctx.character_data: return True raise NoCharacter()