Skip to main content

tansy

PyPI Downloads Code style: black

Unstable experiments with interactions.py.

Commands

tansy provides a unique way to define options for slash commands - a way that appears often in other Discord Python libraries.

Instead of needing a decorator per option or to define the option in one huge list, tansy allows you to define each option in the function itself. By using a special metadata function, you can specify what each argument/parameter in a function should be like as an option, with tansy smartly handling the rest for you.

import interactions as ipy
import tansy

@tansy.slash_command(name="test", description="Nice test command, huh?")
async def test_cmd(
    ctx: ipy.InteractionContext,
    the_user: ipy.User = tansy.Option(name="user", description="The user to ping."),
):
    await ctx.send(the_user.mention)

Class Slash Command

In case you want to try something very unique, or just want to leverage classes, tansy allows you to leverage its toolset to make class slash commands.

import interactions as ipy
import tansy

@tansy.class_slash_command(name="test", description="Nice test command, huh?")
class Test:
    the_user: ipy.User = tansy.Option(name="user", description="The user to ping.")

    async def callback(self, ctx: ipy.InteractionContext):
        await ctx.send(self.the_user.mention)

Note that the class is being read and adjusted to be more like a typical functional declaration, and so isn't a fully true class-based approach. Subclasses are not going to become subcommands (though class_subcommand exists), and while the class does get initialized on every run (meaning you can use custom __init__s, as long as they have no parameters that need to be filled in), the class is largely untouched outside of declaration and using callback.

Metadata

Release files for tansy 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tansy 0.10.0
File Size Uploaded Provenance Actions
tansy-0.10.0.tar.gz 14.7 kB Without provenance Details for tansy-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tansy 0.10.0
File Interpreter ABI Platform Actions
tansy-0.10.0-py3-none-any.whl Python 3 none any Details for tansy-0.10.0-py3-none-any.whl

Total release size: 31.0 kB

Release files / tansy-0.10.0.tar.gz

Download URL tansy-0.10.0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
be7163066825975e35a01bf25a4fcac94db9bcf4a183591eb7d9c59897bc2f5b
BLAKE2b-256 checksum
How to use checksums
b7be025b0bb81e3a8bd63e3c37391c9db7663a26d8026a305c23bd5fe5c175a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Release files / tansy-0.10.0-py3-none-any.whl

Download URL tansy-0.10.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
883c5568335f86c9bcb2483bebe784e74ed29d1510ab96dbe4e2e4391dbbab30
BLAKE2b-256 checksum
How to use checksums
962e4fa0e3935286db1b9df2d5f607cd7133853339ca0a40a15c60d9614947cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.19

Security for tansy 0.10.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page