mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Alias V3] Corrected functions & spelling (#1023)
As discussed with Will in Discord.
This commit is contained in:
parent
d1d8711f60
commit
4d7f065b10
@ -36,7 +36,6 @@ class Alias:
|
||||
|
||||
def __init__(self, bot: Red):
|
||||
self.bot = bot
|
||||
self.file_path = "data/alias/aliases.json"
|
||||
self._aliases = Config.get_conf(self, 8927348724)
|
||||
|
||||
self._aliases.register_global(**self.default_global_settings)
|
||||
@ -119,7 +118,7 @@ class 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.
|
||||
Looks to identify from longest prefix to smallest.
|
||||
@ -128,9 +127,9 @@ class Alias:
|
||||
:param message: Message object
|
||||
:return:
|
||||
"""
|
||||
guild = message.guild
|
||||
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),
|
||||
reverse=True)
|
||||
for p in prefixes:
|
||||
@ -156,7 +155,7 @@ class Alias:
|
||||
async def maybe_call_alias(self, message: discord.Message,
|
||||
aliases: Iterable[AliasEntry]=None):
|
||||
try:
|
||||
prefix = self.get_prefix(message)
|
||||
prefix = await self.get_prefix(message)
|
||||
except ValueError:
|
||||
return
|
||||
|
||||
@ -202,30 +201,30 @@ class Alias:
|
||||
"""
|
||||
Add an alias for a command.
|
||||
"""
|
||||
#region Alias Add Validity Checking
|
||||
# region Alias Add Validity Checking
|
||||
is_command = self.is_command(alias_name)
|
||||
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"
|
||||
" name is already a command on this bot.").format(alias_name))
|
||||
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:
|
||||
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"
|
||||
" alias already exists on this server.").format(alias_name))
|
||||
return
|
||||
|
||||
is_valid_name = self.is_valid_alias_name(alias_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"
|
||||
" name is an invalid alias name. Alias"
|
||||
" names may only contain letters, numbers,"
|
||||
" and underscores and must start with a letter.").format(alias_name))
|
||||
return
|
||||
#endregion
|
||||
# endregion
|
||||
|
||||
# At this point we know we need to make a new alias
|
||||
# and that the alias name is valid.
|
||||
@ -244,21 +243,21 @@ class Alias:
|
||||
# region Alias Add Validity Checking
|
||||
is_command = self.is_command(alias_name)
|
||||
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"
|
||||
" name is already a command on this bot.").format(alias_name))
|
||||
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:
|
||||
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"
|
||||
" alias already exists on this server.").format(alias_name))
|
||||
return
|
||||
|
||||
is_valid_name = self.is_valid_alias_name(alias_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"
|
||||
" name is an invalid alias name. Alias"
|
||||
" names may only contain letters, numbers,"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user