JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 54205
  • Score
    100M100P100Q178048F
  • License MIT

Make configurable canvas easily with Canvafy

Package Exports

  • canvafy
  • canvafy/index.js

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 (canvafy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Canvafy

Make configurable canvas easily with Canvafy

Installation

npm i canvafy

NPM

Example of code (Discord.js v14)

const canvafy = require("canvafy");
const { Client, GatewayIntentBits } = require("discord.js");
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.Presences, GatewayIntentBits.Messages] });

client.on("ready", () => {
  console.log(`I connect to ${client.user.tag}`)
});

Rank card

client.on("messageCreate", async message => {
  if (message.content === "!rank") {
    const rank = await new canvafy.Rank()
    .setAvatar(message.author.displayAvatarURL({ forceStatic: true, extension: "png" }))
    .setBackground("image", "https://th.bing.com/th/id/R.248b992f15fb255621fa51ee0ca0cecb?rik=K8hIsVFACWQ8%2fw&pid=ImgRaw&r=0")
    .setUsername(message.author.username)
    .setDiscriminator(message.author.discriminator)
    .setStatus(message.member.presence?.status)
    .setLevel(2)
    .setRank(1)
    .setCurrentXp(100)
    .setRequiredXp(400)
    .build();

    message.reply({
      files: [{
        attachment: rank.toBuffer(),
        name: `rank-${message.member.id}.png`
      }]
    });
  }
});

img

Welcome card

client.on('guildMemberAdd', async member => {
  const welcome = await new canvafy.WelcomeLeave()
  .setAvatar(member.user.displayAvatarURL({ forceStatic: true, extension: "png" }))
  .setBackground("image", "https://th.bing.com/th/id/R.248b992f15fb255621fa51ee0ca0cecb?rik=K8hIsVFACWQ8%2fw&pid=ImgRaw&r=0")
  .setTitle("Welcome")
  .setDescription("Welcome to this server, go read the rules please!")
  .setBorder("#2a2e35")
  .setAvatarBorder("#2a2e35")
  .setOverlayOpacity(0.3)
  .build();

  member.guild.channels.cache.get("<channelId>").send({
    content: `Welcome to you ${member}!`,
    files: [{
      attachment: welcome.toBuffer(),
      name: `welcome-${member.id}.png`
    }]
  });
});

img

Spotify card

client.on("messageCreate", async message => {
  if (message.content === "!spotify") {
    const spotify = await new canvafy.Spotify()
    .setAuthor("Alan Walker, Ava Max")
    .setAlbum("Alan Walker Album")
    .setBackground("image", "https://th.bing.com/th/id/R.0bbabe949adc2ea6c853eddad2f38519?rik=jshX8YIYBDnF4w&pid=ImgRaw&r=0")
    .setImage("https://i.scdn.co/image/ab67616d00001e02df9a35baaa98675256b35177")
    .setTimestamp(40000, 179000)
    .setTitle("Alone, Pt II")
    .build();

    message.reply({
      files: [{
        attachment: spotify.toBuffer(),
        name: `spotify-${message.member.id}.png`
      }]
    });
  }
});

img

Image > Affect

const canvafy = require("../../index");

client.on("messageCreate", async message => {
  if (message.content === "!affect") {
    const affect = await canvafy.Image.affect("https://i.imgur.com/2pOpPKf.png");

    message.reply({
      files: [{
        attachment: affect.toBuffer(),
        name: `affect-${message.member.id}.png`
      }]
    });
  }
});

img

Leave card

client.on('guildMemberRemove', async member => {
  const leave = await new canvafy.WelcomeLeave()
  .setAvatar(member.user.displayAvatarURL({ format: "png" }))
  .setBackground("image", "https://th.bing.com/th/id/R.248b992f15fb255621fa51ee0ca0cecb?rik=K8hIsVFACWQ8%2fw&pid=ImgRaw&r=0")
  .setTitle("Goodbye")
  .setDescription("Your departure makes us sad")
  .setBorder("#2a2e35")
  .setAvatarBorder("#2a2e35")
  .setOverlayOpacity(0.3)
  .build();

  member.guild.channels.cache.get("<channelId>").send({
    content: `Goodbye to you ${member}!`,
    files: [{
      attachment: leave.toBuffer(),
      name: `leave-${member.id}.png`
    }]
  });
});

client.login("YOUR_TOKEN");

Note

This package is the continuation of discanvas package

Server Support

Discord Banner