Skip to content

Commit b8bde7c

Browse files
committed
Added override_type in case checking type has a problem
1 parent 60374d1 commit b8bde7c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

discord_slash/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class SlashCommand:
1515
:type client: Union[discord.Client, discord.ext.commands.Bot]
1616
:param auto_register: Whether to register commands automatically. Default `False`. Currently not implemented.
1717
:type auto_register: bool
18+
:param override_type: Whether to override checking type of the client and try register event.
19+
:type override_type: bool
1820
1921
:ivar _discord: Discord client of this client.
2022
:ivar commands: Dictionary of the registered commands via :func:`.slash` decorator.
@@ -24,7 +26,8 @@ class SlashCommand:
2426
"""
2527
def __init__(self,
2628
client: typing.Union[discord.Client, commands.Bot],
27-
auto_register: bool = False):
29+
auto_register: bool = False,
30+
override_type: bool = False):
2831
self._discord = client
2932
self.commands = {}
3033
self.subcommands = {}
@@ -33,7 +36,7 @@ def __init__(self,
3336
self.auto_register = auto_register
3437
if self.auto_register:
3538
self.logger.warning("auto_register is NOT implemented! Please manually add commands to Discord API.")
36-
if not isinstance(client, commands.Bot):
39+
if not isinstance(client, commands.Bot) and not override_type:
3740
self.logger.info("Detected discord.Client! Overriding on_socket_response.")
3841
self._discord.on_socket_response = self.on_socket_response
3942
else:

0 commit comments

Comments
 (0)