Package Exports
- img-api
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (img-api) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
IMG API JavaScript
I made an image manipulation API in Golang, primarily targetting Discord Bots.
This is an API wrapper for the api in JavaScript
This wrapper is official and will be kept updated as new stuff gets added.
Install
$ npm install img-apiNo dependencies. TypeScript typings included.
Usage
const { Client } = require("img-api");
// Port defaults to 3030
// Host defaults to localhost
// Password only required if using from a different host and one is set in the server.
const api = new Client({ port: 3030, password: "password", host: "localhost" });
api.ping()
.then(console.log);
api.stats(false)
.then((stats) => console.log(`Version v${stats.version} Up for ${stats.uptime} seconds.`));
// To send images via discord.js
const { MessageAttachment } = require("discord.js");
const buffer = await api.tom(msg.author.displayAvatarURL({ format: "png", size: 2048 }));
someChannel.send(new MessageAttachment(buffer, "name.png"));See Endpoints.md for all endpoints.
The function arguments take arguments in the same order the Endpoints list shows.
Note: The API only accepts
jpgandpngwhen using Discord.js make sure to always ask forpnglike souser.displayAvatarURL({ format: "png" })the default iswebpwhich is not supported.
Changelog
v1.0.0 (19/5/2020)
- Initial release.
v1.0.1
- Fix stats()'s boolean logic
- Add TypeScript typings for
ping/stats
v1.0.2
- Fix
tweet()
License
Released under the MIT License