Skip to main content

Discord API Wrapper in Python

Project description

Welcome to ScurryPy

PyPI version

Yet another 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

  • Command and event handling
  • Declarative style using decorators
  • Supports both legacy and new features
  • Respects Discord's rate limits

Some things to consider...

  • This is an early version — feedback, ideas, and contributions are very welcome! That said, there may be bumps along the way, so expect occasional bugs and quirks.
  • Certain features are not yet supported, while others are intentionally omitted. See the docs for full details.

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.

Note: Adjust dotenv_path if your .env file is not in the same directory as this script.

import discord, os
from dotenv import load_dotenv

load_dotenv(dotenv_path='./path/to/env')

client = discord.Client(
    token=os.getenv("DISCORD_TOKEN"),
    application_id=APPLICATION_ID  # replace with your bot's user ID
)

@client.command(
    command=discord.SlashCommand(
        name='example',
        description='Demonstrate the minimal slash command!'
    ),
    guild_id=GUILD_ID  # must be a guild ID your bot is in
)
async def example(bot: discord.Client, event: discord.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 discord, os
from dotenv import load_dotenv

load_dotenv(dotenv_path='./path/to/env')

client = discord.Client(
    token=os.getenv("DISCORD_TOKEN"),
    application_id=APPLICATION_ID,  # replace with your bot's user ID
    intents=discord.set_intents(message_content=True),
    prefix='!'  # your custom prefix
)

@client.prefix_command
async def ping(bot: discord.Client, event: discord.MessageCreateEvent):
    # The function name is the name of the command
    await event.message.send("Pong!")

client.run()

Like what you see?

Check out 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.3.4.3.tar.gz (37.9 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.3.4.3-py3-none-any.whl (52.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for scurrypy-0.3.4.3.tar.gz
Algorithm Hash digest
SHA256 27407d0383c3c0a9a338df572c0d249eec97fcdf59fc1cb93e6ff724796da996
MD5 9733bd07614d5ea80a302ccb6d2b93aa
BLAKE2b-256 c1ee8d97ac6c15c781690b9ca68e015752bf5d9bfc44ba54b5b2aa1d729fd7a4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scurrypy-0.3.4.3-py3-none-any.whl
  • Upload date:
  • Size: 52.5 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.3.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5493c8560f631e4f49d8a3378ced99d7f5064405669b0272c5397087e66eb333
MD5 4b58b630a4fefddd8c047fe66148ea45
BLAKE2b-256 f7813a45213ee9d646d31d7af866cc6150c22344bd2480d10b01790f10d4a4a7

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