Skip to main content

Dataclass-driven Discord API Wrapper in Python

Project description

ScurryPy

PyPI version

A lightweight, fully readable Discord API framework built to accommodate everything from basic bots to custom frameworks.

While ScurryPy powers many squirrel-related shenanigans, it works just as well for game bots, interactive components, and educational projects.

Features

  • Easy to extend and build frameworks on top
  • Lightweight core (<1000 lines)
  • Command, and event handling
  • Unix shell-style wildcards for component routing
  • Declarative style using decorators
  • Supports both legacy and new features
  • Respects Discord's rate limits
  • No __future__ hacks to avoid circular import
  • Capable of sharding

Getting Started

Note: This section also appears in the documentation, but here are complete examples ready to use with your bot credentials.

Installation

To install the ScurryPy package, run:

pip install scurrypy

Minimal Slash Command

The following demonstrates building and responding to a slash command.

import scurrypy

client = scurrypy.Client(
    token='your-token',
    application_id=APPLICATION_ID  # your bot's application ID
)

@client.command(
    scurrypy.SlashCommand('example', 'Demonstrate the minimal slash command!'), 
    GUILD_ID  # must be a guild ID your bot is in
)
async def example(bot: scurrypy.Client, event: scurrypy.InteractionEvent):
    await event.interaction.respond(f'Hello, {event.interaction.member.user.username}!')

client.run()

Minimal Prefix Command (Legacy)

The following demonstrates building and responding to a message prefix command.

import scurrypy

client = scurrypy.Client(
    token='your-token',
    application_id=APPLICATION_ID,  # your bot's application ID
    intents=scurrypy.set_intents(message_content=True),
    prefix='!'  # your custom prefix
)

@client.prefix_command("ping")
async def on_ping(bot: scurrypy.Client, event: scurrypy.MessageCreateEvent):
    await event.message.send("Pong!")

client.run()

Building on Top of ScurryPy

ScurryPy is designed to be easy to extend with your own abstractions.

The following demonstrates integrating a custom cache into your client configuration:

class CacheProtocol(Protocol):
    async def get_user(self, user_id: int) ...

    # and the rest...

class MyCache(CacheProtocol):
    # your implementation...

class MyConfig(BaseConfig):
    cache: MyCache
    # other stuff here...

client = scurrypy.Client(
    token = 'your-token',
    application_id = 123456789012345,
    config = MyConfig()
)

Like What You See?

Explore the full documentation for more examples, guides, and API reference.

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

scurrypy-0.7.2.2.tar.gz (37.2 kB view details)

Uploaded Source

Built Distribution

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

scurrypy-0.7.2.2-py3-none-any.whl (52.1 kB view details)

Uploaded Python 3

File details

Details for the file scurrypy-0.7.2.2.tar.gz.

File metadata

  • Download URL: scurrypy-0.7.2.2.tar.gz
  • Upload date:
  • Size: 37.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for scurrypy-0.7.2.2.tar.gz
Algorithm Hash digest
SHA256 7fb1ebd0fe35f6b60010624d76f5a1138cf7ee429a79c459f7360039bd0755af
MD5 cd0cfe791e5030afb552acd24ff238b1
BLAKE2b-256 501e7e80f476d3445c28061f3a8e0d6d4e0b251165b251e6241d17d44b031e42

See more details on using hashes here.

File details

Details for the file scurrypy-0.7.2.2-py3-none-any.whl.

File metadata

  • Download URL: scurrypy-0.7.2.2-py3-none-any.whl
  • Upload date:
  • Size: 52.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for scurrypy-0.7.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 808cac7da434ec5be2a95f66fcdaaffbd4839daf38e2c9dbdf2fbf5446dfd005
MD5 81a71175c9971eaf65dcf1a9e805fc7c
BLAKE2b-256 bfaa4d6d0be027a1fca6c9ed5ab9fbeabec6228a8cfa76790ab76c57dbbebfb9

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