[Owner] Show [p]debug result in blocks of 4 messages

This commit is contained in:
Twentysix 2016-11-27 00:42:42 +01:00
parent 9fa2776bda
commit 67de9a45fe

View File

@ -194,9 +194,14 @@ class Owner:
@commands.command(pass_context=True, hidden=True) @commands.command(pass_context=True, hidden=True)
@checks.is_owner() @checks.is_owner()
async def debug(self, ctx, *, code): async def debug(self, ctx, *, code):
"""Evaluates code """Evaluates code"""
def check(m):
if m.content.strip().lower() == "more":
return True
author = ctx.message.author
channel = ctx.message.channel
Modified function, originally made by Rapptz"""
code = code.strip('` ') code = code.strip('` ')
result = None result = None
@ -228,7 +233,25 @@ class Owner:
result = result.replace(w, r) result = result.replace(w, r)
result = result.replace(w.lower(), r) result = result.replace(w.lower(), r)
result = result.replace(w.upper(), r) result = result.replace(w.upper(), r)
for page in pagify(result, shorten_by=12):
result = list(pagify(result, shorten_by=16))
for i, page in enumerate(result):
if i != 0 and i % 4 == 0:
last = await self.bot.say("There are still {} messages. "
"Type `more` to continue."
"".format(len(result) - (i+1)))
msg = await self.bot.wait_for_message(author=author,
channel=channel,
check=check,
timeout=10)
if msg is None:
try:
await self.bot.delete_message(last)
except:
pass
finally:
break
await self.bot.say(box(page, lang="py")) await self.bot.say(box(page, lang="py"))
@commands.group(name="set", pass_context=True) @commands.group(name="set", pass_context=True)