[Alias V3] Corrected functions & spelling (#1023)

As discussed with Will in Discord.
This commit is contained in:
Aioxas 2017-10-16 18:27:02 -04:00 committed by Will
parent d1d8711f60
commit 4d7f065b10

View File

@ -36,7 +36,6 @@ class Alias:
def __init__(self, bot: Red): def __init__(self, bot: Red):
self.bot = bot self.bot = bot
self.file_path = "data/alias/aliases.json"
self._aliases = Config.get_conf(self, 8927348724) self._aliases = Config.get_conf(self, 8927348724)
self._aliases.register_global(**self.default_global_settings) self._aliases.register_global(**self.default_global_settings)
@ -119,7 +118,7 @@ class Alias:
return did_delete_alias return did_delete_alias
def get_prefix(self, message: discord.Message) -> str: async def get_prefix(self, message: discord.Message) -> str:
""" """
Tries to determine what prefix is used in a message object. Tries to determine what prefix is used in a message object.
Looks to identify from longest prefix to smallest. Looks to identify from longest prefix to smallest.
@ -128,9 +127,9 @@ class Alias:
:param message: Message object :param message: Message object
:return: :return:
""" """
guild = message.guild
content = message.content content = message.content
prefixes = sorted(self.bot.command_prefix(self.bot, message), prefix_list = await self.bot.command_prefix(self.bot, message)
prefixes = sorted(prefix_list,
key=lambda pfx: len(pfx), key=lambda pfx: len(pfx),
reverse=True) reverse=True)
for p in prefixes: for p in prefixes:
@ -156,7 +155,7 @@ class Alias:
async def maybe_call_alias(self, message: discord.Message, async def maybe_call_alias(self, message: discord.Message,
aliases: Iterable[AliasEntry]=None): aliases: Iterable[AliasEntry]=None):
try: try:
prefix = self.get_prefix(message) prefix = await self.get_prefix(message)
except ValueError: except ValueError:
return return
@ -205,21 +204,21 @@ class Alias:
# region Alias Add Validity Checking # region Alias Add Validity Checking
is_command = self.is_command(alias_name) is_command = self.is_command(alias_name)
if is_command: if is_command:
await ctx.send(("You attempted to create a new alias" await ctx.send(_("You attempted to create a new alias"
" with the name {} but that" " with the name {} but that"
" name is already a command on this bot.").format(alias_name)) " name is already a command on this bot.").format(alias_name))
return return
is_alias, _ = await self.is_alias(ctx.guild, alias_name) is_alias, something_useless = await self.is_alias(ctx.guild, alias_name)
if is_alias: if is_alias:
await ctx.send(("You attempted to create a new alias" await ctx.send(_("You attempted to create a new alias"
" with the name {} but that" " with the name {} but that"
" alias already exists on this server.").format(alias_name)) " alias already exists on this server.").format(alias_name))
return return
is_valid_name = self.is_valid_alias_name(alias_name) is_valid_name = self.is_valid_alias_name(alias_name)
if not is_valid_name: if not is_valid_name:
await ctx.send(("You attempted to create a new alias" await ctx.send(_("You attempted to create a new alias"
" with the name {} but that" " with the name {} but that"
" name is an invalid alias name. Alias" " name is an invalid alias name. Alias"
" names may only contain letters, numbers," " names may only contain letters, numbers,"
@ -244,21 +243,21 @@ class Alias:
# region Alias Add Validity Checking # region Alias Add Validity Checking
is_command = self.is_command(alias_name) is_command = self.is_command(alias_name)
if is_command: if is_command:
await ctx.send(("You attempted to create a new global alias" await ctx.send(_("You attempted to create a new global alias"
" with the name {} but that" " with the name {} but that"
" name is already a command on this bot.").format(alias_name)) " name is already a command on this bot.").format(alias_name))
return return
is_alias, _ = self.is_alias(ctx.guild, alias_name) is_alias, something_useless = await self.is_alias(ctx.guild, alias_name)
if is_alias: if is_alias:
await ctx.send(("You attempted to create a new alias" await ctx.send(_("You attempted to create a new global alias"
" with the name {} but that" " with the name {} but that"
" alias already exists on this server.").format(alias_name)) " alias already exists on this server.").format(alias_name))
return return
is_valid_name = self.is_valid_alias_name(alias_name) is_valid_name = self.is_valid_alias_name(alias_name)
if not is_valid_name: if not is_valid_name:
await ctx.send(("You attempted to create a new alias" await ctx.send(_("You attempted to create a new global alias"
" with the name {} but that" " with the name {} but that"
" name is an invalid alias name. Alias" " name is an invalid alias name. Alias"
" names may only contain letters, numbers," " names may only contain letters, numbers,"