From 607cde76f49fa3d34acefabf30a5f22aac22396f Mon Sep 17 00:00:00 2001 From: Irdumb Date: Fri, 8 Apr 2016 16:45:47 +1000 Subject: [PATCH] support for sfx list >2k characters didn't add paging to the other list commands as per request be Twentysix?? I may have misunderstood. Doesn't account for sfx with emoji in their names. I'm not sure if that's even possible. --- cogs/audio.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/cogs/audio.py b/cogs/audio.py index 2f13609ea..deabe7172 100644 --- a/cogs/audio.py +++ b/cogs/audio.py @@ -465,16 +465,25 @@ class Audio: @_list.command(name="sfx", pass_context=True) async def list_sfx(self, ctx): - msg = "Available local sound effects: \n\n```" + msgs = ["Available local sound effects: \n\n```\n"] files = self.get_local_sfx() + m = 0 + maxm = 1980 if files: for i, d in enumerate(files.keys()): - if i % 4 == 0 and i != 0: - msg = msg + d + "\n" - else: - msg = msg + d + "\t" - msg += "```" - await self.bot.send_message(ctx.message.author, msg) + if len(d) < maxm: #how did you get a filename this large? + if len(msgs[m]) + len(d) > maxm: + msgs[m] += "```" + m += 1 + msgs.append("```\n") + if i % 4 == 0 and i != 0: + msgs[m] += d + "\n" + else: + msgs[m] += d + "\t" + msgs[m] += "```" + for msg in msgs: + await self.bot.send_message(ctx.message.author, msg) + await asyncio.sleep(1) else: await self.bot.say("There are no local sound effects.")