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)
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 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:
msg = msg + d + "\n"
msgs[m] += d + "\n"
else:
msg = msg + d + "\t"
msg += "```"
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.")