KAJdev/snowfin

Callback loading bug

julien777z opened this issue · 1 comments

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)

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.