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.
This commit is contained in:
Irdumb 2016-04-08 16:45:47 +10:00
parent 3cb7ea02ad
commit 607cde76f4

View File

@ -465,16 +465,25 @@ class Audio:
@_list.command(name="sfx", pass_context=True) @_list.command(name="sfx", pass_context=True)
async def list_sfx(self, ctx): 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() files = self.get_local_sfx()
m = 0
maxm = 1980
if files: if files:
for i, d in enumerate(files.keys()): for i, d in enumerate(files.keys()):
if i % 4 == 0 and i != 0: if len(d) < maxm: #how did you get a filename this large?
msg = msg + d + "\n" if len(msgs[m]) + len(d) > maxm:
else: msgs[m] += "```"
msg = msg + d + "\t" m += 1
msg += "```" msgs.append("```\n")
await self.bot.send_message(ctx.message.author, msg) 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: else:
await self.bot.say("There are no local sound effects.") await self.bot.say("There are no local sound effects.")