Skip to main content

Dataclass-driven Discord API Wrapper in Python

Project description

ScurryPy

PyPI version

A dataclass-driven Discord API wrapper in Python!

While this wrapper is mainly used for various squirrel-related shenanigans, it can also be used for more generic bot purposes.

Features

  • Easy to extend
  • 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

Benchmarks

Not convinced ScurryPy has a place among top libraries? See the benchmarks below!

Test Environment

  • Python: 3.11.6
  • OS: Windows 11
  • Method: New Python process per measurement
  • Tool: See benchmarks folder

Results Summary

Library         Time (ms)    Memory Δ (MB)      Objects
--------------------------------------------------------
scurrypy              8.9             0.44         1417
hikari             1710.3            27.67        53658
discord             252.5             7.64        14099
disnake             185.9             6.31        12111

(See benchmark.py for how this test was done.)

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()

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.6.5.tar.gz (37.8 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.6.5-py3-none-any.whl (50.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for scurrypy-0.6.5.tar.gz
Algorithm Hash digest
SHA256 0a4458c04c58884a93bc8c2c88ecc3df0d0fea84c1b07e9976510ac8b0fb1e59
MD5 f347c7f719d2ccc265e2ce4350d4fabe
BLAKE2b-256 826eaa30bc11b5927969db8a37b93d53b238e44cb5cc3ca94a8c9cbca71d9b6e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scurrypy-0.6.5-py3-none-any.whl
  • Upload date:
  • Size: 50.3 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.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f3373d6ffeac3d2e26697f2ba22902d3c0445b73b89f598fcd16456526e74aa0
MD5 73f4efd4fe65b8c9dbb36f2020a9a8a2
BLAKE2b-256 79c7c99b0fd773d9ec67836bd6cf6290ee33dff0cd9cd7d4744224c4e03c1d29

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