Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

246
Visualizações
Username and number of members will not be updated - Discord.js & canvas

Hey!

I made a bot with canvas and Discord.js v13 that automatically writes a welcome message.

This works so far without any problems. But if a second user joins the server, only the profile picture and not the name will be updated.

How could I fix this? Thank you for your help!


Here is my code that I'm using and some sample images. (please ignore the wrong formatting ^^)

Link to images: https://imgur.com/a/h4NIgGC

const Discord = require("discord.js")
const Canvas = require("canvas")

bot.on("guildMemberAdd", async (member) => {

var welcomeCanvas = {};
welcomeCanvas.create = Canvas.createCanvas(1024, 500)
welcomeCanvas.context = welcomeCanvas.create.getContext("2d")
welcomeCanvas.context.font = 'bold 72px Arial';
welcomeCanvas.context.fillStyle = "#ffffff";

Canvas.loadImage("https://www.misspompadour.de/media/cb/23/bb/1635526572/painting-the-past-persian-grey-kreidefarbe-farbe-wand-ansicht.jpg").then(async (img) => {
    welcomeCanvas.context.drawImage(img, 0, 0, 1024, 500)
    welcomeCanvas.context.fillText("WELCOME", 260, 360);
    welcomeCanvas.context.beginPath();
    welcomeCanvas.context.arc(512, 166, 128, 0, Math.PI * 2, true);
    welcomeCanvas.context.stroke();
    welcomeCanvas.context.fill()
})

const welcomechannel = bot.channels.cache.get("913099401721950259")
    let canvas = welcomeCanvas;
    canvas.context.font = " bold 42px Arial";
    canvas.context.textAlign = "center";
    canvas.context.fillText(member.user.tag.toLocaleUpperCase(), 512, 415)
    canvas.context.font = "bold 32px Arial";
    canvas.context.fillText(`WE ARE NOW ${member.guild.memberCount} MEMBERS`, 512, 465)
    canvas.context.beginPath();
    canvas.context.arc(512, 166, 119, 0, Math.PI * 2, true)
    canvas.context.closePath()
    canvas.context.clip()

    await Canvas.loadImage(member.user.displayAvatarURL({ format: 'png', size: 1024 }))
        .then(img => {
            canvas.context.drawImage(img, 393, 47, 238, 238);
        })
    let attachment = new Discord.MessageAttachment(canvas.create.toBuffer(), `welcome-${member.user.id}.png`)
    welcomechannel.send({ files: [attachment] });

}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda