Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Use add_listener function instead of on_socket_response #45

Closed
burtonwilliamt opened this issue May 28, 2021 · 5 comments
Closed

Use add_listener function instead of on_socket_response #45

burtonwilliamt opened this issue May 28, 2021 · 5 comments

Comments

@burtonwilliamt
Copy link

In this line, I think the intention is add a socket_response listener
https://github.com/kiki7000/discord.py-components/blob/49dafb8f5efa84c655649608b7ffd157b86d0040/discord_components/client.py#L86

However, an unwanted side effect of this way of adding a listener is that it overwrites any other on_socket_response listener function already defined on the bot. I think a better solution would be to use discord.py's Bot.add_listener function:

self.bot.add_listener(on_socket_response, name='socket_response')

This listener will still be called even if some other library/user adds 'socket_response' listeners, and also won't replace existing on_socket_response methods.

@Shaqalito
Copy link

In this line, I think the intention is add a socket_response listener
https://github.com/kiki7000/discord.py-components/blob/49dafb8f5efa84c655649608b7ffd157b86d0040/discord_components/client.py#L86

However, an unwanted side effect of this way of adding a listener is that it overwrites any other on_socket_response listener function already defined on the bot. I think a better solution would be to use discord.py's Bot.add_listener function:

self.bot.add_listener(on_socket_response, name='socket_response')

This listener will still be called even if some other library/user adds 'socket_response' listeners, and also won't replace existing on_socket_response methods.

Fantastic solution to a problem I've passed the passt 7 and a half hours on !

@kiki7000
Copy link
Collaborator

That would be nice
Thank you for the suggestion

@kiki7000
Copy link
Collaborator

kiki7000 commented May 29, 2021

But what if the bot is a client object

@Shaqalito
Copy link

Oof I don't know...

@kiki7000
Copy link
Collaborator

Implemented on 0.5.2.4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants