An external for interactions.py, adding files to CommandContext for file sending
Project description
interactions-files
An external for interactions.py to add files
into CommandContext send.
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.
Credits
- Credits to Toricane for the original idea.
Project details
Release history Release notifications | RSS feed
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.1.tar.gz
(17.3 kB
view hashes)
Built Distribution
Close
Hashes for interactions_files-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a27620c2c028ad0bfa66b8d92e4b9fc7e79509baeda8a9e272e4f555e0d2202 |
|
MD5 | b0b0862227cc26c2c0d6c5239b9b8e65 |
|
BLAKE2b-256 | aad128906de512d1ce91c4d95b954a4a86d8fca15142c79d0abfc244a9c889cd |