From 67de9a45fe67adebc11b58e3c7a16f39c38930c0 Mon Sep 17 00:00:00 2001 From: Twentysix Date: Sun, 27 Nov 2016 00:42:42 +0100 Subject: [PATCH] [Owner] Show `[p]debug` result in blocks of 4 messages --- cogs/owner.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/cogs/owner.py b/cogs/owner.py index c6eae2f7c..72a836009 100644 --- a/cogs/owner.py +++ b/cogs/owner.py @@ -194,9 +194,14 @@ class Owner: @commands.command(pass_context=True, hidden=True) @checks.is_owner() 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('` ') result = None @@ -228,7 +233,25 @@ class Owner: result = result.replace(w, r) result = result.replace(w.lower(), 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")) @commands.group(name="set", pass_context=True)