Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback loading bug #20

Open
julien777z opened this issue Aug 2, 2022 · 1 comment
Open

Callback loading bug #20

julien777z opened this issue Aug 2, 2022 · 1 comment

Comments

@julien777z
Copy link
Contributor

Since commands and callbacks are on each client, calling the decorators snowfin.slash_command, snowfin.select_callback, etc., does not work as it doesn't load the callbacks into the client. Tested with https://github.com/KAJdev/snowfin/blob/main/examples/deferred_example.py and https://github.com/KAJdev/snowfin/blob/main/examples/component_example.py.

It seems like it requires it to be a Module, and load_module() must be called in order to properly load the callbacks into the client.

Simple non-working example:

import snowfin
from snowfin.models import Interaction
import asyncio

bot = snowfin.Client(...)


@snowfin.slash_command(name="hello")
async def on_slash(context: Interaction):
    return snowfin.DeferredResponse(on_slash_defer)

async def on_slash_defer(context: Interaction):
    await asyncio.sleep(1)
    return snowfin.MessageResponse('Ok, *Now* I want to respond ;)')


bot.run("0.0.0.0", 8000, debug=True, auto_reload=True)
@KAJdev
Copy link
Owner

KAJdev commented Aug 2, 2022

That looks like a bug. This should work, as the client collects all “floating” callback objects in the main module, or at least it should. I’ll take a look when I can.

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

No branches or pull requests

2 participants