Skip to content

Repository files navigation

snowfin

An async discord http interactions framework built on top of Sanic.

Installing

Please note that the library requires at least python 3.10

pip install snowfin
#or
poetry add snowfin

Examples

Simple slash command

importasyncioimportsnowfinfromsnowfin.clientimportAutoDeferfromsnowfin.modelsimportInteractionfromsnowfin.responseimportMessageResponsebot=snowfin.Client('public_key', 'application_id', 'token', auto_defer=AutoDefer(enabled=True, timeout=0, ephemeral=True))
@snowfin.slash_command(name="hello")asyncdefhello(context: Interaction):
# we don't have to do anything, just don't return a response until we need toawaitasyncio.sleep(10)
returnMessageResponse('Ok, *Now* I want to respond ;)')
bot.run("0.0.0.0", 80, debug=True)

Slash command with a deferred response

importasyncioimportsnowfinfromsnowfin.modelsimportInteractionfromsnowfin.responseimportDeferredResponse, MessageResponsebot=snowfin.Client('public_key', 'application_id', 'token', auto_defer=True)
@snowfin.slash_command(name="hello")asyncdefon_slash(context: Interaction):
returnDeferredResponse(on_slash_defer)
asyncdefon_slash_defer(context: Interaction):
awaitasyncio.sleep(1)
returnMessageResponse('Ok, *Now* I want to respond ;)')
bot.run("0.0.0.0", 80, debug=True)

You can see more examples here

Links

About

A discord http interactions framework built on top of Sanic

Topics

Resources

Contributing

Stars

12 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages