Skip to content

ForkPrince/stoat-uploader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stoat Uploader

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.

Installation

npm install stoat-uploader

Usage

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.

Uploading from disk

const id = await uploader.file({ file: "/path/to/file.txt" }, bot);

message.channel.sendMessage({
  content: "Here is your file!",
  attachments: [id]
});

Uploading from a URL

const id = await uploader.url({ url: "https://example.com/image.png" }, bot);

message.channel.sendMessage({
  content: "Here is your image!",
  attachments: [id]
});

Uploading raw data

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:

  • attachments
  • avatars
  • backgrounds
  • icons
  • banners
  • emojis

All of these have different configurations and limits. See this file for the exact specifications.

About

Stoat attachment uploader for Bun

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%