A fast, stateless http slash commands framework for scale. Built by the Crunchy bot team.

Related tags

discord slash-commands
Overview

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.

Issues
Releases(0.4.3)
  • 0.4.3(Sep 21, 2021)

    This fixes several issues and adds some new features:

    • Type parsing bugs with commands and checks where the return annotation would be mistaken for an option to parse.
    • Deferred components can now set a local error handler like everything else.
    • App can be passed to commands, checks and other handlers via adding a parameter called app. Unfortunately, It's not possible to do this based on type hinting so the system requires this as a reserved name.
    Source code(tar.gz)
    Source code(zip)
  • 0.2.2(Sep 20, 2021)

    This fixes some spelling errors in the docs as well as some type hints for checks.

    Before they lead you to believe you should still return an Interaction vs returning a Response object.

    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Sep 20, 2021)

  • 0.2.0(Sep 20, 2021)

    This version fixes some cleanup issues with the component system and also allows state to persist between edits where it would have previously been lost causing issues with deleting parents.

    Source code(tar.gz)
    Source code(zip)
  • 0.1.0(Sep 20, 2021)

Owner
Harrison Burt
Programmer in Python, Rust, Js and Go lang.
Harrison Burt
Cement is an advanced Application Framework for Python, with a primary focus on CLI

Cement Framework Cement is an advanced Application Framework for Python, with a primary focus on Command Line Interfaces (CLI). Its goal is to introdu

Data Folk Labs, LLC 1k Oct 25, 2021
Pythonic command line arguments parser, that will make you smile

docopt creates beautiful command-line interfaces Video introduction to docopt: PyCon UK 2012: Create *beautiful* command-line interfaces with Python N

null 7.5k Oct 25, 2021
Cleo allows you to create beautiful and testable command-line interfaces.

Cleo Create beautiful and testable command-line interfaces. Cleo is mostly a higher level wrapper for CliKit, so a lot of the components and utilities

Sébastien Eustace 763 Oct 15, 2021
Typer, build great CLIs. Easy to code. Based on Python type hints.

Typer, build great CLIs. Easy to code. Based on Python type hints. Documentation: https://typer.tiangolo.com Source Code: https://github.com/tiangolo/

Sebastián Ramírez 6.5k Oct 22, 2021
A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables.

ConfigArgParse Overview Applications with more than a handful of user-settable options are best configured through a combination of command line args,

null 544 Oct 18, 2021
CalcuPy 📚 Create console-based calculators in a few lines of code.

CalcuPy ?? Create console-based calculators in a few lines of code. ?? Installation pip install calcupy ?? Usage from calcupy import Calculator calc

Dylan Tintenfich 6 Sep 26, 2021
A thin, practical wrapper around terminal capabilities in Python

Blessings Coding with Blessings looks like this... from blessings import Terminal t = Terminal() print(t.bold('Hi there!')) print(t.bold_red_on_brig

Erik Rose 1.3k Oct 19, 2021
Rich is a Python library for rich text and beautiful formatting in the terminal.

Rich 中文 readme • lengua española readme • Läs på svenska Rich is a Python library for rich text and beautiful formatting in the terminal. The Rich API

Will McGugan 30.4k Oct 24, 2021
Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer.

Textual is a TUI (Text User Interface) framework for Python using Rich as a renderer. The end goal is to be able to rapidly create rich termin

Will McGugan 5.8k Oct 17, 2021
Python library that measures the width of unicode strings rendered to a terminal

Introduction This library is mainly for CLI programs that carefully produce output for Terminals, or make pretend to be an emulator. Problem Statement

Jeff Quast 250 Oct 15, 2021
Python and tab completion, better together.

argcomplete - Bash tab completion for argparse Tab complete all the things! Argcomplete provides easy, extensible command line tab completion of argum

Andrey Kislyuk 991 Oct 22, 2021
Python composable command line interface toolkit

$ click_ Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It's the "Comm

The Pallets Projects 11.5k Oct 24, 2021
emoji terminal output for Python

Emoji Emoji for Python. This project was inspired by kyokomi. Example The entire set of Emoji codes as defined by the unicode consortium is supported

Taehoon Kim 1.3k Oct 16, 2021
Simple cross-platform colored terminal text in Python

Colorama Makes ANSI escape character sequences (for producing colored terminal text and cursor positioning) work under MS Windows. PyPI for releases |

Jonathan Hartley 2.6k Oct 23, 2021
sane is a command runner made simple.

sane is a command runner made simple.

Miguel M. 14 Jul 24, 2021
A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations

ASCIIMATICS Asciimatics is a package to help people create full-screen text UIs (from interactive forms to ASCII animations) on any platform. It is li

null 2.8k Oct 23, 2021
Library for building powerful interactive command line applications in Python

Python Prompt Toolkit prompt_toolkit is a library for building powerful interactive command line applications in Python. Read the documentation on rea

prompt-toolkit 7.3k Oct 23, 2021
Python Command-line Application Tools

Clint: Python Command-line Interface Tools Clint is a module filled with a set of awesome tools for developing commandline applications. C ommand L in

Kenneth Reitz Archive 57 Oct 12, 2021