👾 Simple creating cards using canvas. Welcome, Rank, Info and so on.

Overview

discord-canvas-card

Are you developing a bot using DiscordJS and you need beautiful images created using Canvas?

You can create great welcome, goodbye, rank, info banner images fully customizable using the many easy-to-use features!

TypeScript

👨🏻‍💻 Installation

$ npm install discord-card-canvas

Features

  • 🎨 Canvas only, no third-party libraries
  • 📦 Easy to install & use

🧾 Examples

Example Rank

const canvasRank = await new RankCardBuilder({
    currentLvl: 102,
    currentRank: 563,
    currentXP: 71032,
    requiredXP: 95195,
    backgroundImgURL: 'background_blue.png',
    avatarImgURL: 'avatar.jpg',
    nicknameText: { content: 'xNinja_Catx', font: 'Nunito', color: '#0CA7FF' },
    userStatus: 'idle',
}).build();

// Saving an image
fs.writeFileSync('rank_blue.png', canvasRank.toBuffer());

// Example of sending to a channel
channel.send(files: [{ attachment: canvasRank.toBuffer(), name: 'rank.png' }])

const canvasRank = await new RankCardBuilder({
    currentLvl: 50,
    currentRank: 3,
    currentXP: 23478,
    requiredXP: 68195,
    fontDefault: 'Inter',
    backgroundImgURL: 'background_orange.png',
    avatarImgURL: 'avatar.jpg',
    nicknameText: { content: 'Good_Hateful' },
    userStatus: 'online',
    requiredXPColor: '#7F8381',
    currentXPColor: '#f48b2d',
    avatarBackgroundColor: '#fbbf60',
    colorTextDefault: '#f48b2d',
    progressBarColor: '#f48b2d',
}).build();

fs.writeFileSync('rank_orange.png', canvasRank.toBuffer());

Example Welcome/Leave

let cv = new WelcomeBuilder({
    backgroundImgURL: 'default_background_blue.png',
    fontDefault: 'Inter',
    nicknameText: { color: '#0CA7FF', content: 'ДобраяKnopKa#2575' },
    secondText: { color: '#0CA7FF', content: 'Raccoon Bot Discord' },
    avatarImgURL: 'Sad_KnopKa.gif',
}).build();

fs.writeFileSync('welcome-1.png', canvas1.toBuffer());

let cv = new LeaveBuilder({
    nicknameText: { content: 'ДобраяKnopKa#2575' },
    avatarImgURL: 'Sad_KnopKa.gif',
});
cv.setBackgroundImgURL('default_background_red.png');
cv.setFontDefault('Inter');
cv.setSecondText({ content: 'Raccoon Bot Discord' }).build();

fs.writeFileSync('welcome-2.png', canvas2.toBuffer());

⚠️ For full control when creating a card, use BaseCardBuilder.


Example Info

const canvasInfo = await new InfoCardBuilder({
    backgroundImgURL: 'background_info_blue.png',
    mainText: { content: 'INFORMATION' },
}).build();

fs.writeFileSync('info.png', canvasInfo.toBuffer());

📘 Documentation

📌 Classes

BaseCardBuilder

Creating a base card with a resolution of 800x350 px.

  • mainText - Text above the user's nickname.
  • nicknameText - User's nickname.
  • secondText - Text under the user's nickname.
  • backgroundImgURL - URL to the background image.
  • backgroundColor - Background color (if no background image is selected).
    • Default: '#BBE8FF'
  • avatarImgURL - URL to the avatar user image.
  • avatarBorderColor - The outline color of the user's avatar.
    • Default: '#0CA7FF'
  • avatarBorderStyle - Border type for avatar ('fill' fits transparent avatars)
    • 'fill' or 'stroke'
  • fontDefault - Default font. Applies if a specific font is not selected in the TextCard object.
    • Default: 'Nunito'
  • colorTextDefault - Default text color. Applies if a specific text color is not selected in the Text Card object.
    • Default: '#0CA7FF'

🔹 To simplify the creation of welcome, leave cards, you can use the WelcomeBuilder and LeaveBuilder.


RankCardBuilder

Creating a user rating card with a resolution of 1000x250 px.

  • nicknameText * - User's nickname.
  • currentLvl * - The user's current level.
  • currentRank * - The user's current rank.
  • currentXP * - The user's current experience.
  • requiredXP * - Required experience to the next level
  • userStatus * - User status.
  • backgroundImgURL - URL to the background image.
  • backgroundColor - Background color (if no background image is selected).
    • Default: '#BBE8FF'
  • avatarImgURL - URL to the avatar user image.
  • avatarBackgroundEnable - Whether the circle behind the avatar is enabled.
    • Default: True
  • avatarBackgroundColor - The color of the circle behind the avatar.
    • Default: '#0CA7FF'
  • fontDefault - Default font. Applies if a specific font is not selected in the TextCard object.
    • Default: 'Nunito'
  • colorTextDefault - Default text color. Applies if a specific text color is not selected in the Text Card object.
    • Default: '#0CA7FF'
  • progressBarColor - The color of the progress bar.
    • Default: '#0CA7FF'
  • currentXPColor - The color of the current experience number.
    • Default: '#0CA7FF'
  • requiredXPColor - The color of the required experience number.
    • Default: '#7F8384'
  • lvlPrefix - Text before the level number.
    • Default: 'LVL'
  • rankPrefix - Text before the rank number.
    • Default: 'RANK'

🔹 * - Required parameters


InfoCardBuilder

Creating a card-an information header.

  • backgroundImgURL - URL to the background image.
  • backgroundColor - Background color (if no background image is selected).
  • mainText - The main text on the card.

✍️ Important: To create a canvas object, use the build() method of the class.


🔖 Additional Types and Interfaces

  • Color - String - RGB | RGBA | HEX
  • FontResolvable - String - 'Inter' | 'Nunito' | 'Manrope'
  • UserStatus - String - 'online' | 'idle' | 'dnd' | 'offline' | 'streaming'
  • BorderStyle - String - 'fill' | 'stroke'
  • TextCard - { content: string; color?: Color; font?: FontResolvable; }

💎 Contributing

If you have a request for a new feature you can open an issue on Github.

📄 Credits

Made by gusarovv with ❤️

You might also like...

Create info-boxes in a simple way

Create-infoboxes-in-Mediawiki Create info-boxes in a simple way/用简单的方式创建Mediawiki信息栏 Due to some bugs in the infobox extension, I gotta use table to m

Mar 29, 2022

Welcome contributers❤️🎉. Just add your name, Github profile link and Linkedin link🔗 Look at Readme for more.📖

Welcome contributers❤️🎉. Just add your name, Github profile link and Linkedin link🔗 Look at Readme for more.📖

Hello Welcome Developers! Step - 1 Create a GitHub account, if you don't already have one. Step - 2 Register for Hacktoberfest: Navigate to the Hackto

Oct 31, 2022

Welcome To Amru Ser Wa Bot🙂. Tnx to ABUSER❤️

Welcome To Amru Ser Wa Bot🙂.             Tnx to ABUSER❤️

Project created by AMRU-SER to make it public | © | Reserved | Setup Click Instagram logo to follow this page 👇 Simple Method The Hard Method GET QR

Jan 1, 2023

Welcome to Space Traveler's HUB, this web app allows the user to take a fictional tour across the space.

Welcome to Space Traveler's HUB, this web app allows the user to take a fictional tour across the space.

Welcome to Space Traveler's HUB, this web app allows the user to take a fictional tour across the space. The user can choose a rocket from our catalog interface, and reserve it. Also, the user can see recent special missions and join them. Finally, the user will be able to keep track of all your rockets and mission they are subscribed to. Build with React, Redux, React-router, and Railwindcss.

Jan 27, 2022

Completely free TS/JS one-file source code snippets with tests, which can be copied to avoid extra dependencies (contributions welcome).

TinySource Completely free TS/JS one-file source code snippets with tests, which can be copied to avoid extra dependencies (contributions welcome). Sn

Jan 3, 2023

From the Linux Foundation office in New York City, welcome to The Untold Stories of Open Source

From the Linux Foundation office in New York City, welcome to The Untold Stories of Open Source

From the Linux Foundation office in New York City, welcome to The Untold Stories of Open Source. Each week we explore the people who are supporting Open Source projects, how they became involved with it, and the problems they faced along the way.

Jan 5, 2023

This a collaborative repository to us play with javascript basics. Welcome here!

This a collaborative repository to us play with javascript basics. Welcome here!

➡️ PT-BR A HacktoberFest project to put your frontend skills to the test. About This is a beginner-friendly repository for educational purposes that w

Nov 22, 2022

pokedev.js is a tool make to help developers get info about a pokemon and use it in any project with ease.

pokedev.js is a tool make to help developers get info about a pokemon and use it in any project with ease.

pokedev.js pokedev.js is a tool make to help developers get info about a pokemon and use it in any project with ease. Quick Links pokedev.js Quick Lin

Apr 4, 2022

An open source movie library platform for viewing movie info and saving movies for later.

An open source movie library platform for viewing movie info and saving movies for later.

GoodWatch An open source movie library platform for viewing movie info and saving movies for later. How to get started? Fork and clone the repo. Then

Apr 28, 2022
Releases(v1.2.3)
Owner
Gusarov
Gusarov
Benefit cards API, create and store card data and log transactions

Valex ?? Benefit cards for companies and employees! ?? Tech used Overview An API to store benefit cards from companies to employees and log transactio

Felipe Ventura 2 Apr 25, 2022
Unfurl links into rich cards, as seen in places like Slack and Twitter

eleventy-plugin-unfurl Turn URLs into rich cards. Show a preview image, page title, description and other meta information all inside a neatly present

David Darnes 38 Dec 16, 2022
Cards Against Humanity Game Client made with ⚡Nextron (Next.js + Electron) and Typescript

CAH Client Introduction This project is one of the other projects related to the Cards Against Humanity (CAH) game. This client is made in Electron, u

null 3 Jun 17, 2022
Additional themes for Lovelace Mushroom Cards 🍄

?? Mushroom Themes Mushroom themes allow you to customize your Mushroom dashboard using Home Assistant themes. ⚠️ It's only a theme! You need to insta

Paul Bottein 127 Dec 24, 2022
Customizable Codegrepper Stat cards.

CodeGrepper Cards Render your grepper data on your profile. The average server reponse is around 3seconds on the first request. Config Base URL https:

Jareer Abdullah 1 Apr 24, 2022
A free & open source project to save your passwords, notes & credit cards

Free & open source project to save your passwords, notes & credit cards with a clean console UI with multiples features such as show information/create information/delete information

null 4 Aug 8, 2022
A front-end only implementation of linked template cards for Lovelace

Linked Lovelace by @daredoes A Javascript/Websocket way to do templating in the Lovelace UI Support Hey you! Help me out for a couple of ?? or a ☕ ! F

Daniel Evans 13 Dec 12, 2022
A simple tool to search Termux packages and their info.

Termux package search A simple tool to search Termux packages and their info. Runs completely in the browser, and works offline after the first load a

null 5 Dec 1, 2022
The (extremely) lightweight alternative to the mmenu.js plugin for creating off-canvas mobile menus.

mmenu light The (extremely) lightweight alternative to the mmenu.js plugin for creating off-canvas mobile menus with the exact look and feel. Examples

Fred Heusschen 172 Dec 12, 2022