Skip to content

Commit cffa3bc

Browse files
committed
Better event overriding
1 parent dc57b70 commit cffa3bc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

discord_slash/client.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,15 @@ def __init__(self,
5050
elif self.auto_delete:
5151
self._discord.loop.create_task(self.delete_unused_commands())
5252

53-
if not isinstance(client, commands.Bot) and not isinstance(client,
54-
commands.AutoShardedBot) and not override_type:
55-
self.logger.info("Detected discord.Client! Overriding on_socket_response.")
56-
self._discord.on_socket_response = self.on_socket_response
53+
if not isinstance(client, commands.Bot) and not isinstance(client, commands.AutoShardedBot) and not override_type:
54+
self.logger.info("Detected discord.Client! It is highly recommended to use `commands.Bot`.")
55+
original_sock_event = self._discord.on_socket_response
56+
57+
def wrap(*args):
58+
original_sock_event(*args)
59+
self.on_socket_response(*args)
60+
61+
self._discord.on_socket_response = wrap
5762
self.has_listener = False
5863
else:
5964
if not hasattr(self._discord, 'slash'):

0 commit comments

Comments
 (0)