|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
5 | | -import asyncio |
6 | 5 | from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Sequence, Tuple, Union |
7 | 6 |
|
8 | 7 | from disnake.app_commands import MessageCommand, UserCommand |
9 | 8 | from disnake.flags import ApplicationInstallTypes, InteractionContextTypes |
10 | 9 | from disnake.i18n import Localized |
11 | 10 | from disnake.permissions import Permissions |
| 11 | +from disnake.utils import iscoroutinefunction |
12 | 12 |
|
13 | 13 | from .base_core import InvokableApplicationCommand, _get_overridden_method |
14 | 14 | from .errors import CommandError |
@@ -124,9 +124,8 @@ async def _call_external_error_handlers( |
124 | 124 | stop_propagation = await local(inter, error) |
125 | 125 | # User has an option to cancel the global error handler by returning True |
126 | 126 | finally: |
127 | | - if stop_propagation: |
128 | | - return # noqa: B012 |
129 | | - inter.bot.dispatch("user_command_error", inter, error) |
| 127 | + if not stop_propagation: |
| 128 | + inter.bot.dispatch("user_command_error", inter, error) |
130 | 129 |
|
131 | 130 | async def __call__( |
132 | 131 | self, |
@@ -236,9 +235,8 @@ async def _call_external_error_handlers( |
236 | 235 | stop_propagation = await local(inter, error) |
237 | 236 | # User has an option to cancel the global error handler by returning True |
238 | 237 | finally: |
239 | | - if stop_propagation: |
240 | | - return # noqa: B012 |
241 | | - inter.bot.dispatch("message_command_error", inter, error) |
| 238 | + if not stop_propagation: |
| 239 | + inter.bot.dispatch("message_command_error", inter, error) |
242 | 240 |
|
243 | 241 | async def __call__( |
244 | 242 | self, |
@@ -337,7 +335,7 @@ def user_command( |
337 | 335 | def decorator( |
338 | 336 | func: InteractionCommandCallback[CogT, UserCommandInteraction, P], |
339 | 337 | ) -> InvokableUserCommand: |
340 | | - if not asyncio.iscoroutinefunction(func): |
| 338 | + if not iscoroutinefunction(func): |
341 | 339 | raise TypeError(f"<{func.__qualname__}> must be a coroutine function") |
342 | 340 | if hasattr(func, "__command_flag__"): |
343 | 341 | raise TypeError("Callback is already a command.") |
@@ -445,7 +443,7 @@ def message_command( |
445 | 443 | def decorator( |
446 | 444 | func: InteractionCommandCallback[CogT, MessageCommandInteraction, P], |
447 | 445 | ) -> InvokableMessageCommand: |
448 | | - if not asyncio.iscoroutinefunction(func): |
| 446 | + if not iscoroutinefunction(func): |
449 | 447 | raise TypeError(f"<{func.__qualname__}> must be a coroutine function") |
450 | 448 | if hasattr(func, "__command_flag__"): |
451 | 449 | raise TypeError("Callback is already a command.") |
|
0 commit comments