Skip to main content

Unstable experiments with NAFF.

Project description

tansy

PyPI Downloads Code style: black

Unstable experiments with NAFF.

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.

Example Command

import naff
import tansy

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

Speedups

tansy also includes several patches that can speed up NAFF itself, sometimes by a signficant margin. However, these patches are unstable, and may break some (usually niche) parts of the things they modify.

To install them, use:

import tansy

# this should be the first line of code you run in your main file if you want
# everything to work correctly
tansy.install_naff_speedups()

You can also toggle on or off what patches you want - take a look at the function's docstring for details.

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

tansy-0.5.2.tar.gz (14.4 kB view hashes)

Uploaded Source

Built Distribution

tansy-0.5.2-py3-none-any.whl (16.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page