A fast, stateless http slash commands framework for scale. Built by the Crunchy bot team.
Project description
Roid 🤖
A fast, stateless http slash commands framework for scale. Built by the Crunchy bot team.
🚀 Installation
You can install roid in it's default configuration via:
pip install roid
You can install with the optional speedups e.g. orjson with:
pip install roid[speedups]
📚 Getting Started
You can get started with the following options, most of the public API is type hinted and a lot of the framework depends around this so you should be able to stand on your own two feet reasonable quickly.
- Examples are the best / only place to start.
✨ Basic Example
import os
import uvicorn
import roid
application_id = os.getenv("APPLICATION_ID")
public_key = os.getenv("PUBLIC_KEY")
token = os.getenv("BOT_TOKEN")
app = roid.SlashCommands(application_id, public_key, token)
# We can create async commands
@app.command("echo", "Echo a message.", guild_id=675647130647658527)
async def echo(message: str):
return Response(content=message, flags=ResponseFlags.EPHEMERAL)
# Or sync commands which are ran in another thread.
# While this is not advised for everything, we do provide threadsafe interfaces
# to the state management system.
@app.command("echo-sync", "Echo a message with threading.", guild_id=675647130647658527)
def echo_sync(message: str):
return Response(content=message, flags=ResponseFlags.EPHEMERAL)
if __name__ == "__main__":
app.register_commands_on_start()
uvicorn.run("app:app", port=8000)
❤️ Developer Note
Please note that this library is largely designed around what we need the framework to do rather than strictly as a general API framework.
You may notice rather opinionated things e.g. how we work command groups. Which are a trait of that. These things are generally subject to change with Discord but right now we thing the standard command groups look rather poor.
This framework is not for everyone, if you need the gateway or general REST api calls this is probably not the framework for you. (Although if you would like to add some more of the slash commands REST api then feel free to PR.)
This is also why there generally arent any forms of online docs for this, i'll get around to it, eventually.
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
File details
Details for the file roid-0.8.1.tar.gz
.
File metadata
- Download URL: roid-0.8.1.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 11b8b92daf47be12dfdac45fcd916dc6a59c2ecdc6bfd295e939322df263fb7d |
|
MD5 | 94008da87ebc032015ddf47a44034295 |
|
BLAKE2b-256 | 0a212de8c06378bf5aa4288bdd73635d686629469e648a80aab4740aa7ef601e |