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

199
Views
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
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!