diff --git a/discord/commands/core.py b/discord/commands/core.py index 0a5e1fa457..e3c904c1af 100644 --- a/discord/commands/core.py +++ b/discord/commands/core.py @@ -254,7 +254,7 @@ async def __call__(self, ctx, *args, **kwargs): convert the arguments beforehand, so take care to pass the correct arguments in. """ - if self.cog: + if self.cog is not None: return await self.callback(self.cog, ctx, *args, **kwargs) return await self.callback(ctx, *args, **kwargs) @@ -392,7 +392,7 @@ async def can_run(self, ctx: ApplicationContext) -> bool: predicates = self.parent.checks + predicates cog = self.cog - if cog: + if cog is not None: local_check = cog._get_overridden_method(cog.cog_check) if local_check is not None: ret = await maybe_coroutine(local_check, ctx) @@ -414,13 +414,13 @@ async def dispatch_error(self, ctx: ApplicationContext, error: Exception) -> Non pass else: injected = wrap_callback(coro) - if cog: + if cog is not None: await injected(cog, ctx, error) else: await injected(ctx, error) try: - if cog: + if cog is not None: local = cog.__class__._get_overridden_method(cog.cog_command_error) if local is not None: wrapped = wrap_callback(local) @@ -544,7 +544,7 @@ async def call_after_hooks(self, ctx: ApplicationContext) -> None: await self._after_invoke(ctx) # type: ignore # call the cog local hook if applicable: - if cog: + if cog is not None: hook = cog.__class__._get_overridden_method(cog.cog_after_invoke) if hook is not None: await hook(ctx) @@ -998,7 +998,7 @@ async def _invoke(self, ctx: ApplicationContext) -> None: if o._parameter_name not in kwargs: kwargs[o._parameter_name] = o.default - if self.cog: + if self.cog is not None: await self.callback(self.cog, ctx, **kwargs) elif self.parent is not None and self.attached_to_group is True: await self.callback(self.parent, ctx, **kwargs)