fix error handling
This commit is contained in:
1 parent
b5863b9e27
commit
58908ee3d6
2 files changed
+17
-11
No files matched your search
+5
-3
@@ -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")
|
||||
|
||||
|
||||
|
||||
+12
-8
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user