update for d.py 1.3 (#3445)

* update for d.py 1.3

* Update redbot/core/commands/commands.py

Co-Authored-By: Danny <Rapptz@users.noreply.github.com>

* a few more places we use owner info

* add the cli flag + handling

* set fix

* Handle MaxConcurrencyReached.

* Bump `aiohttp-json-rpc`

Co-authored-by: Danny <Rapptz@users.noreply.github.com>
Co-authored-by: Kowlin <Kowlin@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Michael H
2020-01-25 18:59:08 -05:00
committed by GitHub
parent 498d0d22fb
commit 2ac4dde729
7 changed files with 91 additions and 27 deletions

View File

@@ -330,15 +330,27 @@ class Command(CogCommandMixin, commands.Command):
if not change_permission_state:
ctx.permission_state = original_state
async def _verify_checks(self, ctx):
async def prepare(self, ctx):
ctx.command = self
if not self.enabled:
raise commands.DisabledCommand(f"{self.name} command is disabled")
if not (await self.can_run(ctx, change_permission_state=True)):
if not await self.can_run(ctx, change_permission_state=True):
raise commands.CheckFailure(
f"The check functions for command {self.qualified_name} failed."
)
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)
async def do_conversion(
self, ctx: "Context", converter, argument: str, param: inspect.Parameter
):
@@ -625,14 +637,14 @@ class Group(GroupMixin, Command, CogGroupMixin, commands.Group):
if ctx.invoked_subcommand is None or self == ctx.invoked_subcommand:
if self.autohelp and not self.invoke_without_command:
await self._verify_checks(ctx)
await self.can_run(ctx, change_permission_state=True)
await ctx.send_help()
elif self.invoke_without_command:
# So invoke_without_command when a subcommand of this group is invoked
# will skip the the invokation of *this* command. However, because of
# how our permissions system works, we don't want it to skip the checks
# as well.
await self._verify_checks(ctx)
await self.can_run(ctx, change_permission_state=True)
# this is actually why we don't prepare earlier.
await super().invoke(ctx)
@@ -778,6 +790,3 @@ class _AlwaysAvailableCommand(Command):
async def can_run(self, ctx, *args, **kwargs) -> bool:
return not ctx.author.bot
async def _verify_checks(self, ctx) -> bool:
return not ctx.author.bot

View File

@@ -757,16 +757,10 @@ class _RulesDict(Dict[Union[int, str], PermState]):
def _validate_perms_dict(perms: Dict[str, bool]) -> None:
invalid_keys = set(perms.keys()) - set(discord.Permissions.VALID_FLAGS)
if invalid_keys:
raise TypeError(f"Invalid perm name(s): {', '.join(invalid_keys)}")
for perm, value in perms.items():
try:
attr = getattr(discord.Permissions, perm)
except AttributeError:
attr = None
if attr is None or not isinstance(attr, property):
# We reject invalid permissions
raise TypeError(f"Unknown permission name '{perm}'")
if value is not True:
# We reject any permission not specified as 'True', since this is the only value which
# makes practical sense.