mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 19:28:54 -05:00
add in aliaslist command - not putting it in group so anyone can use it
This commit is contained in:
parent
9a3668799f
commit
08c861ef02
@ -78,6 +78,20 @@ class Alias:
|
|||||||
fileIO("data/alias/aliases.json", "save", self.aliases)
|
fileIO("data/alias/aliases.json", "save", self.aliases)
|
||||||
await self.bot.say("Alias '{}' deleted.".format(command))
|
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):
|
async def check_aliases(self, message):
|
||||||
if message.author.id == self.bot.user.id or \
|
if message.author.id == self.bot.user.id or \
|
||||||
len(message.content) < 2 or message.channel.is_private:
|
len(message.content) < 2 or message.channel.is_private:
|
||||||
@ -98,11 +112,13 @@ class Alias:
|
|||||||
def part_of_existing_command(self, alias, server):
|
def part_of_existing_command(self, alias, server):
|
||||||
'''Command or alias'''
|
'''Command or alias'''
|
||||||
for command in self.bot.commands:
|
for command in self.bot.commands:
|
||||||
if alias.startswith(command):
|
if alias.lower() == command:
|
||||||
return True
|
return True
|
||||||
if server not in self.aliases:
|
if server not in self.aliases:
|
||||||
return False
|
return False
|
||||||
if alias.split(" ")[0] in self.aliases[server]:
|
for curr_alias in self.aliases[server]:
|
||||||
|
if alias.split(" ")[0] == curr_alias \
|
||||||
|
and alias != curr_alias:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user