From 08c861ef02277ef7f358eff848ac3d4610c7b05f Mon Sep 17 00:00:00 2001 From: Will Tekulve Date: Thu, 14 Apr 2016 00:40:15 -0400 Subject: [PATCH] add in aliaslist command - not putting it in group so anyone can use it --- cogs/alias.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cogs/alias.py b/cogs/alias.py index 40339db88..26332b79b 100644 --- a/cogs/alias.py +++ b/cogs/alias.py @@ -78,6 +78,20 @@ class Alias: fileIO("data/alias/aliases.json", "save", self.aliases) await self.bot.say("Alias '{}' deleted.".format(command)) + @commands.command(pass_context=True) + async def aliaslist(self, ctx): + server = ctx.message.server + if server.id in self.aliases: + message = "```Alias list:\n" + for alias in sorted(self.aliases[server.id]): + if len(message) + len(alias) + 3 > 2000: + await self.bot.say(message) + message = "```\n" + message += "\t{}\n".format(alias) + if len(message) > 4: + message += "```" + await self.bot.say(message) + async def check_aliases(self, message): if message.author.id == self.bot.user.id or \ len(message.content) < 2 or message.channel.is_private: @@ -98,12 +112,14 @@ class Alias: def part_of_existing_command(self, alias, server): '''Command or alias''' for command in self.bot.commands: - if alias.startswith(command): + if alias.lower() == command: return True if server not in self.aliases: return False - if alias.split(" ")[0] in self.aliases[server]: - return True + for curr_alias in self.aliases[server]: + if alias.split(" ")[0] == curr_alias \ + and alias != curr_alias: + return True return False def remove_old(self):