How to use the canvas-constructor.sepia function in canvas-constructor

To help you get started, we’ve selected a few canvas-constructor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SharifPoetra / yumeko / commands / fun / sepia.js View on Github external
module.exports.run = async (client, msg, args) => {
  let user = msg.mentions.users.first() || client.users.get(args[0]);
  if (!user) user = msg.author;
  try {
    const paintMess = await msg.channel.send("🖌️ Painting...");
    const png = user.avatarURL.replace(/\.gif/g, ".png");
    const { body } = await client.snek.get(png);
    const avatar = await loadImage(body);
    let newSepia = new Canvas(avatar.width, avatar.height)
      .addRect(0, 0, avatar.width, avatar.height)
      .setColor("#000000")
      .addImage(body, 0, 0, avatar.width, avatar.height);
    newSepia = sepia(newSepia)
      .toBuffer();
    await paintMess.delete();
    return msg.channel.send(new Attachment(newSepia, "sepia.png"));
  } catch (e) {
    return msg.channel.send(`Oh no an error occured :( \`${e.message}\` try again later`);
  }
};

canvas-constructor

A ES6 class for node-canvas with built-in functions and chained methods.

MIT
Latest version published 5 months ago

Package Health Score

78 / 100
Full package analysis