conflict fixes
This commit is contained in:
@ -263,7 +263,7 @@ class MessageConverter(Converter):
|
||||
3. Lookup by message URL
|
||||
|
||||
.. versionchanged:: 1.5
|
||||
Raise :exc:`.ChannelNotFound`, `MessageNotFound` or `ChannelNotReadable` instead of generic :exc:`.BadArgument`
|
||||
Raise :exc:`.ChannelNotFound`, :exc:`.MessageNotFound` or :exc:`.ChannelNotReadable` instead of generic :exc:`.BadArgument`
|
||||
"""
|
||||
async def convert(self, ctx, argument):
|
||||
id_regex = re.compile(r'(?:(?P<channel_id>[0-9]{15,21})-)?(?P<message_id>[0-9]{15,21})$')
|
||||
|
@ -144,7 +144,7 @@ class Command(_BaseCommand):
|
||||
The long help text for the command.
|
||||
brief: Optional[:class:`str`]
|
||||
The short help text for the command.
|
||||
usage: :class:`str`
|
||||
usage: Optional[:class:`str`]
|
||||
A replacement for arguments in the default help text.
|
||||
aliases: Union[List[:class:`str`], Tuple[:class:`str`]]
|
||||
The list of aliases the command can be invoked under.
|
||||
@ -778,17 +778,22 @@ class Command(_BaseCommand):
|
||||
if not await self.can_run(ctx):
|
||||
raise CheckFailure('The check functions for command {0.qualified_name} failed.'.format(self))
|
||||
|
||||
if self.cooldown_after_parsing:
|
||||
await self._parse_arguments(ctx)
|
||||
self._prepare_cooldowns(ctx)
|
||||
else:
|
||||
self._prepare_cooldowns(ctx)
|
||||
await self._parse_arguments(ctx)
|
||||
|
||||
if self._max_concurrency is not None:
|
||||
await self._max_concurrency.acquire(ctx)
|
||||
|
||||
await self.call_before_hooks(ctx)
|
||||
try:
|
||||
if self.cooldown_after_parsing:
|
||||
await self._parse_arguments(ctx)
|
||||
self._prepare_cooldowns(ctx)
|
||||
else:
|
||||
self._prepare_cooldowns(ctx)
|
||||
await self._parse_arguments(ctx)
|
||||
|
||||
await self.call_before_hooks(ctx)
|
||||
except:
|
||||
if self._max_concurrency is not None:
|
||||
await self._max_concurrency.release(ctx)
|
||||
raise
|
||||
|
||||
def is_on_cooldown(self, ctx):
|
||||
"""Checks whether the command is currently on cooldown.
|
||||
@ -1140,6 +1145,7 @@ class GroupMixin:
|
||||
self.all_commands[command.name] = command
|
||||
for alias in command.aliases:
|
||||
if alias in self.all_commands:
|
||||
self.remove_command(command.name)
|
||||
raise CommandRegistrationError(alias, alias_conflict=True)
|
||||
self.all_commands[alias] = command
|
||||
|
||||
@ -1172,7 +1178,12 @@ class GroupMixin:
|
||||
|
||||
# we're not removing the alias so let's delete the rest of them.
|
||||
for alias in command.aliases:
|
||||
self.all_commands.pop(alias, None)
|
||||
cmd = self.all_commands.pop(alias, None)
|
||||
# in the case of a CommandRegistrationError, an alias might conflict
|
||||
# with an already existing command. If this is the case, we want to
|
||||
# make sure the pre-existing command is not removed.
|
||||
if cmd not in (None, command):
|
||||
self.all_commands[alias] = cmd
|
||||
return command
|
||||
|
||||
def walk_commands(self):
|
||||
|
@ -289,7 +289,7 @@ class ChannelNotFound(BadArgument):
|
||||
|
||||
Attributes
|
||||
-----------
|
||||
channel: :class:`str`
|
||||
argument: :class:`str`
|
||||
The channel supplied by the caller that was not found
|
||||
"""
|
||||
def __init__(self, argument):
|
||||
|
Reference in New Issue
Block a user