Note: This project requires Bun as its runtime.
stoat.js doesn't offer the ability to upload attachments, so here is a utility package to allow easy file uploads.
npm install stoat-uploader
First, import the uploader library:
const uploader = require("stoat-uploader");You need to have a bot (client) object initialized and logged in. Then you can use the uploader methods to upload files.
const id = await uploader.file({ file: "/path/to/file.txt" }, bot);
message.channel.sendMessage({
content: "Here is your file!",
attachments: [id]
});const id = await uploader.url({ url: "https://example.com/image.png" }, bot);
message.channel.sendMessage({
content: "Here is your image!",
attachments: [id]
});const buffer = Buffer.from("hello world");
const id = await uploader.raw({ file: buffer, name: "hello.txt", type: "text/plain" }, bot);
message.channel.sendMessage({
content: "Here is your text file!",
attachments: [id]
});You can also specify a different tag for your upload (default is attachments). Available tags:
attachmentsavatarsbackgroundsiconsbannersemojis
All of these have different configurations and limits. See this file for the exact specifications.