Skip to main content

An external for interactions.py, adding files to CommandContext for file sending

Project description

interactions-files

An extension library for interactions.py allowing files in interaction responses.

How to use

It is pretty straight forward. Here is an example.

import interactions

client = interactions.Client(...)

client.load('interactions.ext.files')

After that, you can use use files in CommandContext to send file. Take an example below.

import interactions
import io

client = interactions.Client(...)
client.load('interactions.ext.files')

@client.command(
    name="file",
    description="Send a message as a text file",
    options=[
        interactions.Option(
            type=interactions.OptionType.STRING,
            name="message",
            description="Message",
            required=True
        )
    ]
)
async def _file(ctx: interactions.CommandContext, message: str):
    file = io.StringIO(message)
    with file as f:
        file = interactions.File(filename="message.txt", fp=f)
        await ctx.send(files=file)


client.start()

You can use it in an Extension, a.k.a Cogs. Just load interactions.ext.files and you are done.

If you need an in-depth explanation on how interactions-files can be used, check out the examples folder.

Credits

  • Credits to Toricane for the original idea.

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

interactions-files-1.0.3.tar.gz (17.3 kB view hashes)

Uploaded Source

Built Distribution

interactions_files-1.0.3-py3-none-any.whl (17.3 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