Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
Trying to create a welcome image code with Jimp (Latest version: 0.16.1) as well, using latest version of Discord.js (13.6.0). I'm trying for hours

I'm facing a problem trying to develop a bot... I'm trying to to make a "welcome image" with Jimp (Coding with Javascript) for my bot. Everything works fine, except the jimp part [Using the client.on("guildMemberAdd", async member => code. The code is showed below:

client.on("guildMemberAdd", async member => {
  
  let channel = client.guilds.cache.get('932114971935014982')
  let mask = await jimp.read('mascara.png')
  let background = await jimp.read('download.jpg')

  await jimp.read(member.user.displayAvatarURL({format: 'jpg'})).then(async avatar => {
  avatar.resize(130, 130)
  mask.resize(130,130)
  avatar.mask(mask)

  background.composite(avatar, 10, 20).write('SenseiAvatar.jpg')
  await channel.send(``, { files: ["SenseiAvatar.jpg"]})

  console.log('Imagem de boas-vindas ao novo Sensei enviada com sucesso!')
  })
  .catch(err => {
  console.log('There was an error loading the image')
  })
})

If someone can help me, showing me which things are wrong in my code, I'll be so much praised by it!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't really know jimp but I really recommend you canvas. It's very easy to make welcome images.

Example welcome image with canvas:

const Canvas = require("canvas");
const { MessageAttachment } = require("discord.js");

client.on("guildMemberAdd", async (member) => {
  const user = member.user

  canvas = Canvas.createCanvas(1024, 500);
  const ctx = canvas.getContext("2d");

  const font = "sans-serif"
  const font_color = "#ffffff"
  const bg_color = "#000000"
  const title = `${user.username} has joined the server`
  const subtitle = "YOUR SUBTITLE HERE"

  ctx.fillStyle = bg_color;
  ctx.fillRect(0, 0, canvas.width, canvas.height);

  ctx.font = `42px ${font}`;
  ctx.textAlign = "center";
  ctx.fillStyle = font_color;
  ctx.fillText(title, 512, 390, 950);

  ctx.font = `32px ${font}`;
  ctx.fillStyle = font_color;
  ctx.fillText(subtitle, 512, 440, 950);

  ctx.beginPath();
  ctx.arc(512, 179, 129, 0, Math.PI * 2, true);
  ctx.stroke();
  ctx.fill();

  ctx.beginPath();
  ctx.arc(512, 179, 119, 0, Math.PI * 2, true);
  ctx.closePath();
  ctx.clip();

  const avatar = await Canvas.loadImage(
    user.displayAvatarURL({ format: "jpg", size: 1024 })
  );
  ctx.drawImage(avatar, 393, 60, 238, 238);

  const channel = await member.guild.channels.cache.get("CHANNEL_ID");

  attachment = new MessageAttachment(canvas.toBuffer(), "card.png");
  await channel.send({
    content: `<@${user.id}>, welcome`,
    files: [attachment],
  });
});
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda