#How can i make in canvas the pfp of the user be centred on the middle

15 messages · Page 1 of 1 (latest)

umbral anvil
#

Hi, I wanna make a wlc system

#

But it doesn't display the username of the new member

#
const Canvas = require("@napi-rs/canvas");
const { request } = require("undici");

module.exports = {
    name: Events.GuildMemberAdd,

    async execute(member) {
        const canvas = Canvas.createCanvas(965, 487);
        const context = canvas.getContext("2d");

        const background = await Canvas.loadImage("./wallpaper.jpg");

        context.drawImage(background, 0, 0, canvas.width, canvas.height);
        context.strokeStyle = "#000000";
        context.strokeRect(0, 0, canvas.width, canvas.height);

        context.font = "60px Aeshtetic-Normal";

        context.fillStyle = "#6d7578";

        context.fillText(member.displayName, canvas.width / 2.5, canvas.height / 1.8);

        context.beginPath();

        context.arc(125, 125, 100, 0, Math.PI * 2, true);

        context.closePath();

        context.clip();

        const { body } = await request(member.user.displayAvatarURL({ extension: "jpg" }));
        const avatar = await Canvas.loadImage(await body.arrayBuffer());

        context.drawImage(avatar, 25, 25, 200, 200);

        const attachment = new AttachmentBuilder(await canvas.encode("png"), { name: "image.png"});

        const wlcChannnel = member.guild.channels.cache.get("1117900229459591278");
        wlcChannnel.send({ files: [attachment] });
    },
};
waxen minnow
#

That font probably isn’t loaded

umbral anvil
#

see

waxen minnow
#

Try with something easy like serif first

umbral anvil
umbral anvil
waxen minnow
# umbral anvil

Just because the file exists on your drive doesn’t mean it’s loaded into canvas

umbral anvil
#

i understand

umbral anvil
umbral anvil
#

Hello

#

New Error And Code