This is a welcome image generator for Discord that uses node-canvas to create images. This module allows customizing the welcome image.
If you only need to use image generation, you only need to put card.js into your project.
- Installation Dependencies
npm i canvas stackblur-canvas opentype.js
-
Put
card.js
into your project -
Download the
fonts
folder and put it in the same directory ascard.js
(If you want to customize the font, you don't need to.)
const imagebuffer = await wCard.CreateImageCard(
'BACKGROUND IMAGE URL',
'AVATAR URL',
'WELCOME!',
'Title',
'Subtitle',
{
boderblur:90,
bgblur:20
},
{
WelcomeTextSize: 34,
TitleSize: 62,
SubtitleSize: 24
}
)
Example of image generator
// import card.js
const {WelcomeCard} = require('./card.js');
Initialization settings
(font position, etc., if the default font is used then leave blank)
// Use default font on fonts folder
//const wCard = new WelcomeCard()
const wCard = new WelcomeCard({
WelcomeTextFont: "./fonts/NaikaiFont-Bold.ttf",
Titlefont: "./fonts/NotoSansTC-Black.otf",
SubTitleFont: "./fonts/NaikaiFont-Bold.ttf"
})
Preload font files.
// Preload font files
wCard.LoadFonts().then( ()=>{console.log('Fonts loaded.')} )
Create image.
//Create Image Buffer
const imagebuffer = await wCard.CreateImageCard(
'BACKGROUND IMAGE URL',
'AVATAR URL',
'WELCOME!',
'Title',
'Subtitle'
)
Example of Discordbot and use Docker
version: "3.9"
services:
DiscordWelcomeBot:
image: "ghcr.io/interfacegui/discord-welcome-image-bot:latest"
environment:
BGIMAGEURL: "BACKGROUND IMAGE URL"
TOKEN: "YOUR Discord TOKEN"
GUILDID: "YOUR Discord ServerID"
W_CHANNEL: "Your Welcome Channel ID"
INFO_CHANNEL: "Your Log Channel ID"
WTEXT: "Welcome!"
MTEXT: "Member Count"
-
BGIMAGEURL
Background image url put here. -
TOKEN
Discord bot token -
GUILDID
Your server ID -
W_CHANNEL
Welcome channel ID -
INFO_CHANNEL
User join TAG channel ID
(This is used to allow administrators to view users. It will only TAG the user once on the INFO channel.) -
WTEXT
Welcome Text (ex. Welcome!) -
MTEXT
Subitile text (ex. Member Count: 123)