Package Exports
- discord-card-canvas
- discord-card-canvas/dist/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 (discord-card-canvas) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
β 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'
- Default:
avatarImgURL
- URL to the avatar user image.avatarBorderColor
- The outline color of the user's avatar.- Default:
'#0CA7FF'
- Default:
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'
- Default:
colorTextDefault
- Default text color. Applies if a specific text color is not selected in the Text Card object.- Default:
'#0CA7FF'
- Default:
πΉ 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 leveluserStatus *
- User status.backgroundImgURL
- URL to the background image.backgroundColor
- Background color (if no background image is selected).- Default:
'#BBE8FF'
- Default:
avatarImgURL
- URL to the avatar user image.avatarBackgroundEnable
- Whether the circle behind the avatar is enabled.- Default:
True
- Default:
avatarBackgroundColor
- The color of the circle behind the avatar.- Default:
'#0CA7FF'
- Default:
fontDefault
- Default font. Applies if a specific font is not selected in the TextCard object.- Default:
'Nunito'
- Default:
colorTextDefault
- Default text color. Applies if a specific text color is not selected in the Text Card object.- Default:
'#0CA7FF'
- Default:
progressBarColor
- The color of the progress bar.- Default:
'#0CA7FF'
- Default:
currentXPColor
- The color of the current experience number.- Default:
'#0CA7FF'
- Default:
requiredXPColor
- The color of the required experience number.- Default:
'#7F8384'
- Default:
lvlPrefix
- Text before the level number.- Default:
'LVL'
- Default:
rankPrefix
- Text before the rank number.- Default:
'RANK'
πΉ
*
- Required parameters
- Default:
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 | HEXFontResolvable
- String - 'Inter' | 'Nunito' | 'Manrope'UserStatus
- String - 'online' | 'idle' | 'dnd' | 'offline' | 'invisible' | '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 β€οΈ