Skip to main content

A lightweight framework for discord interactions over http built on FastAPI

Project description

Read the docs here

Install fastapi-interactions

pip install fastapi-interactions

Quick example

from fastapi_interactions import Bot
from fastapi_interactions.commands import (
    CommandRouter, option,
)

bot = Bot(app_id='DISCORD_APP_ID',
          public_key='DISCORD_PUBLIC_KEY',
          bot_token='DISCORD_BOT_TOKEN')

router = CommandRouter()


@router.command('helloworld', 'say hello')
async def hello(ctx):
    return 'hello'


@router.command('echo', 'echo a phrase back')
@option('text', 'the text to repeat')
async def echo(ctx, text: str):
    return text

bot.attach_router(router)

bot.sync_commands()  # Use only on build time if running on vercel
app = bot.app

[!WARNING]

SYNCING COMMANDS

If you are on a serverless architecture like Vercel, make sure you only call bot.sync_commands during build time. You do not want this being executed every time you receive an interaction in production.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_interactions-0.0.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_interactions-0.0.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_interactions-0.0.1.tar.gz.

File metadata

  • Download URL: fastapi_interactions-0.0.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for fastapi_interactions-0.0.1.tar.gz
Algorithm Hash digest
SHA256 162cf5cdf6d931b90bb0bc66f65356f5c166aa5957c9ba010e9e517f7aac308a
MD5 f064ef5f72040c9e9e42e656947f29b1
BLAKE2b-256 2db2349668b7b711d061e8d16bcb958ecf86ad5357580c674c1fe4dd8d075232

See more details on using hashes here.

File details

Details for the file fastapi_interactions-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_interactions-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b93c389307d712257cfbe3d357a8358d144d035c9fea075e61d6f01f464633a8
MD5 ec98cea0e58266a4482d99c197d67d1b
BLAKE2b-256 4c1497ff47155fd53796e47326020bd9c1e52b7dc69ae5e172e963e1424713d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page