discanvas
v2.0.3
Published
Simple canvas with discanvas
Downloads
61
Maintainers
Readme
discanvas
From simple image with configurable canvas
More canvas coming soon
Simple canvas with discanvas
V2.0.3
Example of code
const discanvas = require('discanvas');
const { Client, Intents } = require('discord.js');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_PRESENCES,
Intents.FLAGS.GUILD_MESSAGES,
]
});
client.on('ready', () => {
console.log('I connect to ' + client.user.tag)
});
client.on('messageCreate', async message => {
if (message.content === '!rankcard') {
const rankcard = await new discanvas.RankCard()
.setAvatar('https://cdn.discordapp.com/avatars/' + message.member.id + '/' + message.author.avatar + '.png')
.setLevel(1)
.setCurrentXP(200)
.setRequiredXP(400)
.setProgressBar('#ff5555')
.setStatus(message.member.presence?.status)
.setUsername(message.author.username)
.setDiscriminator(message.author.discriminator)
.setTop(1)
.setBackground('BACKGROUND', 'https://cdn.discordapp.com/attachments/819995259261288475/835055559941292032/style.jpg')
//or : .setBackground('COLOR', '#ff5555')
.setSquareOpacity(0.5)
.setBorderColor('#00ff55')
.toCard()
message.reply({ files: [{ attachment: rankcard.toBuffer(), name: 'rankcard-' + message.member.id + '.png' }] });
}
});
client.on('guildMemberAdd', async member => {
const welcome = await new discanvas.Welcome()
.setAvatar('https://cdn.discordapp.com/avatars/' + member.id + '/' + member.user.avatar + '.png')
.setUsername(message.author.username)
.setDiscriminator(message.author.discriminator)
.setBackground('BACKGROUND', 'https://cdn.discordapp.com/attachments/819995259261288475/835055559941292032/style.jpg')
//or : .setBackground('COLOR', '#ff5555')
.setMainText('Welcome')
.setSecondText('We are now ' + member.guild.memberCount + ' in the guild !')
/*
.setCircleColor('#ff5555')
.setMainTextColor('#ff5555')
.setSecondTextColor('#ff5555')
.setPseudoColor('#ff5555')
*/
.toWelcome()
member.guild.channels.cache.get('channelId').send({ content: 'Welcome ' + member.toString(), files: [{ attachment: welcome.toBuffer(), name: 'welcome-' + member.id + '.png' }] });
});
client.on('guildMemberRemove', async member => {
const leave = await new discanvas.Leave()
.setAvatar('https://cdn.discordapp.com/avatars/' + member.id + '/' + member.user.avatar + '.png')
.setUsername(message.author.username)
.setDiscriminator(message.author.discriminator)
.setBackground('BACKGROUND', 'https://cdn.discordapp.com/attachments/819995259261288475/835055559941292032/style.jpg')
//or : .setBackground('COLOR', '#ff5555')
.setMainText('Goodbye')
.setSecondText('Your departure makes us sad')
/*
.setCircleColor('#ff5555')
.setMainTextColor('#ff5555')
.setSecondTextColor('#ff5555')
.setPseudoColor('#ff5555')
*/
.toLeave()
member.guild.channels.cache.get('channelId').send({ content: 'Goodbye ' + member.toString(), files: [{ attachment: leave.toBuffer(), name: 'leave-' + member.id + '.png' }] });
});
client.login('YOUR_TOKEN');