Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Intentando crear un código de imagen de bienvenida con Jimp (Última versión: 0.16.1) también, usando la última versión de Discord.js (13.6.0). Estoy tratando durante horas

Estoy enfrentando un problema al tratar de desarrollar un bot... Estoy tratando de hacer una "imagen de bienvenida" con Jimp (Codificación con Javascript) para mi bot. Todo funciona bien, excepto la parte del jimp [Usando el código client.on("guildMemberAdd", miembro asíncrono => ). El código se muestra a continuación:

 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') }) })

Si alguien puede ayudarme, mostrándome qué cosas están mal en mi código, ¡seré muy elogiado por ello!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Realmente no conozco jimp pero realmente te recomiendo canvas . Es muy fácil hacer imágenes de bienvenida.

Ejemplo de imagen de bienvenida con 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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!