guildMemberAdd - Canvas

Hello, when a member joins my server a canva is generated the problem is that if my member has special characters in his nickname, the canva displays squares.
10 Replies
d.js toolkit
d.js toolkit•10mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - ✅ Marked as resolved by OP
Aiwoz[old]
Aiwoz[old]•10mo ago
const canvas = Canvas.createCanvas(700, 250);
const context = canvas.getContext('2d');
const background = await Canvas.loadImage(`./assets/background.png`);
const applyText = (canvas, text) => {
let fontSize = 60;
do {
context.font = `${fontSize -= 10}px arial`;
} while (context.measureText(text).width > canvas.width - 295);
return context.font;
};
context.drawImage(background, 0, 0, canvas.width, canvas.height);
context.font = `bold 36px arial`;
context.fillStyle = `#ffffff`;
context.fillText(`Bienvenue sur le serveur !`, canvas.width / 3, canvas.height / 2.7);
context.font = applyText(canvas, `${user.displayName}`);
context.fillStyle = `#ffffff`;
context.fillText(`${user.displayName}`, canvas.width / 2.55, canvas.height / 1.5);
context.beginPath();
context.arc(118, 125, 100, 0, Math.PI * 2, true);
context.closePath();
context.clip();
const { body } = await request(user.displayAvatarURL({ extension: 'png' }));
const avatar = await Canvas.loadImage(await body.arrayBuffer());
context.drawImage(avatar, 18, 25, 200, 200);
const attachment = new AttachmentBuilder(await canvas.encode('png'), { name: 'profile-image.png' });
member.guild.channels.cache.get(welcomeChannel).send({ files: [attachment] });
const canvas = Canvas.createCanvas(700, 250);
const context = canvas.getContext('2d');
const background = await Canvas.loadImage(`./assets/background.png`);
const applyText = (canvas, text) => {
let fontSize = 60;
do {
context.font = `${fontSize -= 10}px arial`;
} while (context.measureText(text).width > canvas.width - 295);
return context.font;
};
context.drawImage(background, 0, 0, canvas.width, canvas.height);
context.font = `bold 36px arial`;
context.fillStyle = `#ffffff`;
context.fillText(`Bienvenue sur le serveur !`, canvas.width / 3, canvas.height / 2.7);
context.font = applyText(canvas, `${user.displayName}`);
context.fillStyle = `#ffffff`;
context.fillText(`${user.displayName}`, canvas.width / 2.55, canvas.height / 1.5);
context.beginPath();
context.arc(118, 125, 100, 0, Math.PI * 2, true);
context.closePath();
context.clip();
const { body } = await request(user.displayAvatarURL({ extension: 'png' }));
const avatar = await Canvas.loadImage(await body.arrayBuffer());
context.drawImage(avatar, 18, 25, 200, 200);
const attachment = new AttachmentBuilder(await canvas.encode('png'), { name: 'profile-image.png' });
member.guild.channels.cache.get(welcomeChannel).send({ files: [attachment] });
Danial
Danial•10mo ago
That's not discord.js-related, #useful-servers / #other-js-ts
Aiwoz[old]
Aiwoz[old]•10mo ago
Oh, sorry.
Danial
Danial•10mo ago
No worries
Aiwoz[old]
Aiwoz[old]•10mo ago
Can you delete this "channel" ?
Aiwoz[old]
Aiwoz[old]•10mo ago
Thank you and Merry Christmas. 😉
Danial
Danial•10mo ago
Of course, and you too <:NM_peepoSanta:761185987749347338>
Aiwoz[old]
Aiwoz[old]•10mo ago
^^
Want results from more Discord servers?
Add your server