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

200
Vistas
How to wrap text in Node canvas?

hey so I've made this command for my discord bot using canvas that just quotes something a user says, but the image is only able to fit 26 characters of text, if I write something longer than that, the rest of the characters wont be visible, so I wanted to know if there is some method to wrap the rest of the text? I cant find anything on wrapping text in node canvas Text

here is my code:

client.on("message", async (message) => {
  if (message.author.bot) return;
  if (message.content.startsWith("R!write")) {
let sliced = message.content.slice(31)
let msg = `"${sliced}" - 2021`
const { registerFont, createCanvas } = require('canvas')
const canvas = Canvas.createCanvas(1920, 900);
let background = await Canvas.loadImage('./lmao.jpg');
const ctx = canvas.getContext('2d')
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
registerFont('./disc2.otf', { family: 'Comic Sans' })

const taggeduser = message.mentions.users.first();
if (!taggeduser)
return message.channel.send('mention someone pleb')

let avatar = await Canvas.loadImage(taggeduser.displayAvatarURL({ dynamic: false, format: 'jpg', size: 256 }));
ctx.drawImage(avatar, 160, 340);

ctx.font = '100px "Comic Sans"'
ctx.fillText(msg, 500, 500)

let attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'example.png')



    return message.channel.send(attachment);
  }
});

about 4 years ago · Juan Pablo Isaza
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