npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

zoro-api

v0.3.5

Published

An api to generate images / gifs !

Downloads

11

Readme

Presentation

Zoro API is an API that generates images with filters to enhance your photos !

Installation

npm i --save zoro-api

Configuration

The first step is to import the module in your code.

const Zoro = require("zoro-api");

Then you have to request your image and send it as an attachement. Be careful, if you want to use animated filters (gifs), you will have to modify the extension of the gif type instead of png.

//Import the discord.js library
const Discord = require("discord.js");

//Create a new discord.js client
const bot = new Discord.Client()

//Import the module
const Zoro = require("zoro-api");

//Listen to the ready event
bot.on("ready", () => {
    console.log("The robot is online !");  
})

//Listen to the message event
bot.on("message", async (message) => {
    //If the user types !blur
    if (message.content === "!blur") {
    	//Get user
        let user = message.mentions.users.first() || message.author;
        //Get the avatarUrl of the user
        let avatar = user.displayAvatarURL({ size: 512 }).replace(".webp", ".png")
        //Loading message
        const msg = await message.channel.send("Generating ...")
        //Generating the image
        let img = await Zoro.blur(avatar)
        //Adding the image as an attachement
        let attachment = new Discord.MessageAttachment(img, "blur.png");
        //Sending the image and delete the loading message
        message.channel.send(attachment) && msg.delete();
    }
})

//Log in to the bot
bot.login("Token")

Available endpoints

PNG :

  • .tv(Avatar)
  • .bw(Avatar)
  • .ps4(Avatar)
  • .gay(Avatar)
  • .jail(Avatar)
  • .blur(Avatar)
  • .trash(Avatar)
  • .pixel(Avatar)
  • .sepia(Avatar)
  • .invert(Avatar)
  • .circle(Avatar)
  • .ps4pegi(Avatar)
  • .contrast(Avatar)
  • .convolute(Avatar)

GIFS :

  • .error(Avatar)
  • .triggered(Avatar)

RANDOM GIFS :

  • .cry()
  • .hug()
  • .kiss()
  • .bang()
  • .wasted()

RANDOM PICTURES :

  • .cat()
  • .dog()

CREATE GIFS :

  • .cgif(Avatar, "Link of an image")

Advanced

How to generate an image in an embed ? (Example with the blur filter).

bot.on("message", async (message) => {
    //If the user types !blur
    if (message.content === "!blur") {
    	//Get user
        let user = message.mentions.users.first() || message.author;
        //Get the avatarUrl of the user
        let avatar = user.displayAvatarURL({ size: 512 }).replace(".webp", ".png")
        //Loading message
        const msg = await message.channel.send("Generating ...")
        //Generating the image
        let img = await Zoro.blur(avatar)
        //Adding the image as an attachement
        let attachment = new Discord.MessageAttachment(img, "blur.png");
        //New embed
        const embed = {
            //The bot displays the name of the user
            title: `Blur, user ${user.username}`,
            //Attachment
            image: {
                url: 'attachment://blur.png',
            },
        };
        //Sending the image (with embed) and delete the loading message
        message.channel.send(({ files: [attachment], embed: embed })) && msg.delete();
    }
})

How to generate an image with a link ? (Example with the blur filter).

Zoro.blur("Link")

It is also possible to get the link from a command. Example !blur http://image.png.

//Listen to the message event
client.on("message", async (message) => {
    //If the user types !blur
    if (message.content.startsWith("!img")) {
        //Get args (link)
        let messageArray = message.content.split(' ');
        let args = messageArray.slice(1);
        //If no link
        if (!args[0]) return message.channel.send("Please indicate the link of an image !")
        //Loading message
        const msg = await message.channel.send("Generating ...")

        try {

            //Generating the image
            let img = await Zoro.blur(args.join(" "))
            //Adding the image as an attachement
            let attachment = new Discord.MessageAttachment(img, "blur.png");
            //Sending the image and delete the loading message
            message.channel.send(attachment) && msg.delete();

        } catch (e) {

            //The bot sends the error to the console
            console.log(e)
            //Error message
            return message.channel.send("An error occured, please check the link of your image !") && msg.delete();

        }

    }
})

How to design a custom gif ? Example !cgif http://image.png.

//Listen to the message event
client.on("message", async (message) => {
    //If the user types !cgif
    if (message.content.startsWith("!cgif")) {
        //Get args (link)
        let messageArray = message.content.split(' ');
        let args = messageArray.slice(1);
        //Get user
        let user = message.mentions.users.first() || message.author;
        //Get the avatarUrl of the user
        let avatar = user.displayAvatarURL({ size: 512 }).replace(".webp", ".png")
        //If no link
        if (!args[0]) return message.channel.send("Please indicate the link of an image !")
        //Loading message
        const msg = await message.channel.send("Generating ...")

        try {

            //Generating the image
            let img = await Zoro.cgif(avatar, args.join(" "))
            //Adding the image as an attachement
            let attachment = new Discord.MessageAttachment(img, "cgif.gif");
            //Sending the image and delete the loading message
            message.channel.send(attachment) && msg.delete();

        } catch (e) {

            //The bot sends the error to the console
            console.log(e)
            //Error message
            return message.channel.send("An error occured, please check the link of your image !") && msg.delete();

        }

    }
})

Discord server

Do you have a question? Problem? Join the server discord.

Contributors

Thanks to Mr¤KayJayDee for contributing to the project.