Discord API Wrapper in Python
Project description
Welcome to ScurryPy
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scurrypy-0.3.4.2.tar.gz.
File metadata
- Download URL: scurrypy-0.3.4.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83f72c2cdf43c50583fcf0342617ee069c9d8eaa7eb6fdb8e265594560c3a7ea
|
|
| MD5 |
c5fe1068b6d682ced7e81c2e8cac27e5
|
|
| BLAKE2b-256 |
c601487c358deb5e925099e3a80fc9d69aced57074b76b6f82312356b33b964a
|
File details
Details for the file scurrypy-0.3.4.2-py3-none-any.whl.
File metadata
- Download URL: scurrypy-0.3.4.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7c2cf7df09511c07a47645b480c1156b94e99dd506bab05caebda95e1fdb110
|
|
| MD5 |
4c93f556732b2c27f9430055e30382ba
|
|
| BLAKE2b-256 |
0e54ec4f43dfffe9bcb7c52c3acbb54ca1fa9250c3f4ec905bcc8a11a3699534
|