Skip to main content

Seamless integration between Typer and Discord.py for CLI Discord bots

Project description

t2d

t2d is a short for Typer-to-Discord. It implements a seamless integration between Typer and Discord.py for CLI Discord bots development.

Installing

Just install the package using pip install t2d.

How to use it?

Assume that you have a Typer app that looks something like this:

import typer
app = typer.Typer()

@app.command()
def hello(name: str):
    typer.echo(f"Hello {name}!")

@app.command()
def bye(name: str):
    typer.echo(f"Bye {name}!")

All you have to do is:

import t2d
bot = t2d.T2D(app)
bot.run(YOUR_DISCORD_BOT_TOKEN)

And that's it! Now you can use your Typer app in Discord! Default commands are:

!help    Shows default help message for the bot
!t2d     Runs Typer CLI app using T2D
!version Prints T2D version

Using the example above, you can do the following:

!t2d hello Gabriel -> Shows "Hello Gabriel!"
!t2d bye Gabriel   -> Shows "Bye Gabriel!"

Extending T2D

One can also extend T2D as it normally would using the discord.ext.commands.Bot API.

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

t2d-0.1.4.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

t2d-0.1.4-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file t2d-0.1.4.tar.gz.

File metadata

  • Download URL: t2d-0.1.4.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.7 Linux/5.13.0-28-generic

File hashes

Hashes for t2d-0.1.4.tar.gz
Algorithm Hash digest
SHA256 92561cb2fa5b77c9a79c17b36efa21a502c075c9cfdd33cf60302f6b46276c76
MD5 62f3412562d1c366308ae5115ba75fae
BLAKE2b-256 c4fcb708b0e5bea7972591df1639aca870d0c33b264c5150b9f0ef5357208f3f

See more details on using hashes here.

File details

Details for the file t2d-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: t2d-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.9.7 Linux/5.13.0-28-generic

File hashes

Hashes for t2d-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fc67129181b5272329a5c544a13038065ea17b796bcf0773c7697adf074d15b6
MD5 94e646643aebe274f1b4695d65285b2b
BLAKE2b-256 af8a021612c03760c32d7e5696be02f7393691a6515698d034442db951cab02c

See more details on using hashes here.

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