diff --git a/botclass.py b/botclass.py index c35f580..8bc1b2e 100644 --- a/botclass.py +++ b/botclass.py @@ -34,18 +34,20 @@ class CustomCtx(Context): send content in a paginated codeblock """ codeblock = "```" + lang + "\n{}" + "\n```" - if not len(content) > 1200: + if not len(content) > 1900: await self.send(content=codeblock.format(content)) return pages = [] string = "" - for p in content.splitlines("\n"): + for p in content.splitlines(): if not len(string) > 1900: - string += p + string += p + '\n' else: pages.append(codeblock.format(string)) string = "" string += p + if string: + pages.append(string) await self.paginate(pages=pages, pagetype="text") diff --git a/exts/misc.py b/exts/misc.py index 895abf2..7383eb1 100644 --- a/exts/misc.py +++ b/exts/misc.py @@ -74,19 +74,23 @@ class Misc(commands.Cog): try: result = await self.kit.query( "nations", - {"alliance_id": 10177, - "orderBy": OrderBy("cities", Order.DESC) + {"alliance_id": id, + "orderBy": OrderBy("cities", Order.DESC), + "first": 300 }, "id, nation_name, num_cities, alliance {name}" ) + string = f"Nations in alliance {result.nations[0].alliance.name}\n" + i=0 + for nation in result.nations: + i+=1 + string += f"{i:>3}. {nation.id} c{nation.num_cities} {nation.nation_name}\n" + await ctx.cbsend(string) + except IndexError: + return await ctx.send("> alliance not found.") except Exception as e: return await ctx.cbsend(e) - string = f"Nations in alliance {result.nations[0].alliance.name}\n" - i=0 - for nation in result.nations: - i+=1 - string += f"{i:>3}. {nation.id} c{nation.num_cities} {nation.nation_name}\n" - await ctx.cbsend(string) +