From cab5b23b0b19de10fe60be73e47263cfc736a30b Mon Sep 17 00:00:00 2001 From: Twentysix Date: Tue, 29 Mar 2016 00:06:14 +0200 Subject: [PATCH] Support for over 2k characters in CCs list --- cogs/customcom.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cogs/customcom.py b/cogs/customcom.py index 630f7ec27..0b27ac551 100644 --- a/cogs/customcom.py +++ b/cogs/customcom.py @@ -95,11 +95,18 @@ class CustomCommands: if server.id in self.c_commands: cmdlist = self.c_commands[server.id] if cmdlist: - msg = "```Custom commands:\n" + i = 0 + msg = ["```Custom commands:\n"] for cmd in sorted([cmd for cmd in cmdlist.keys()]): - msg += " {}{}\n".format(ctx.prefix, cmd) - fmsg = msg + "```" - await self.bot.whisper(fmsg) + if len(msg[i]) + len(ctx.prefix) + len(cmd) + 5 > 2000: + msg[i] += "```" + i += 1 + msg.append("``` {}{}\n".format(ctx.prefix, cmd)) + else: + msg[i] += " {}{}\n".format(ctx.prefix, cmd) + msg[i] += "```" + for cmds in msg: + await self.bot.whisper(cmds) else: await self.bot.say("There are no custom commands in this server. Use addcom [command] [text]") else: