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

128
Views
Bot no envía Canvas - discord.js

Estoy haciendo un bot de prueba en discord.js que envía tarjetas de perfil cuando se llama al comando $profile. Pero no tengo experiencia con Canvas, así que busqué en Google algunos tutoriales y los seguí.

Pero el problema es que el bot no envía el archivo adjunto, he intentado investigar otras formas de hacerlo pero tampoco funcionan.

Este es el código del lienzo.

 const Canvas = require('canvas') const Discord = require("discord.js"); module.exports = { name: 'profile', description: '', run: async (client, message) => { const profilecanvas = Canvas.createCanvas(660,315) const ctx = profilecanvas.getContext('2d') const bg = await Canvas.loadImage('https://i.imgur.com/______.png') ctx.drawImage(bg, 0, 0, profilecanvas.width, profilecanvas.height); ctx.strokeStyle = '#fdfd34'; ctx.strokeRect(0, 0, profilecanvas.width, profilecanvas.height); const attachment = new Discord.MessageAttachment(profilecanvas.toBuffer(), bg); message.channel.send('testing', attachment) } }

Y manda el "testing" normalmente, solo que el Canvas no se envía y no aparece error de sintaxis en el terminal

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Intente pasar un parámetro de tipo MessageOptions , con una propiedad de attachments cuyo valor sea una matriz con su attachment como su único elemento, y una propiedad de content de valor "testing":

 message.channel.send({ attachments: [attachment], content: "testing", });
about 4 years ago · Santiago Trujillo Report

0

usar

 message.channel.send({files: [attachment]});

y si desea tener una imagen y texto en un mensaje, entonces

 message.channel.send({ files: [attachment], content: 'Message text' });

about 4 years ago · Santiago Trujillo 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!