Canvas help (discord.js)


i need help with the assets area
i want my bot to use canvas but it cant load the image i have in assets
Picture 2:
(node:4749) UnhandledPromiseRejectionWarning: Error: error while reading from input stream

at Image.src (/rbd/pnpm-volume/bfc224d2-0f81-4f4f-aa60-bb35a754e1e3/node_modules/

at Promise (/rbd/pnpm-volume/bfc224d2-0f81-4f4f-aa60-bb35a754e1e3/node_modules/

at new Promise (<anonymous>)

at Object.loadImage (/rbd/pnpm-volume/bfc224d2-0f81-4f4f-aa60-bb35a754e1e3/node_modules/

at Client.client.on (/app/server.js:41:37)

tconst Discord = require(‘discord.js’);
const client = new Discord.Client();
const Canvas = require(‘canvas’);
client.on(‘guildMemberAdd’, async member => {
const channel = member.guild.channels.find(ch => === ‘member-log’);
if (!channel) return;

const canvas = Canvas.createCanvas(700, 250);
const ctx = canvas.getContext('2d');

// Since the image takes time to load, you should await it
const background = await Canvas.loadImage('./wallpaper.jpg');
// This uses the canvas dimensions to stretch the image onto the entire canvas
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
// Use helpful Attachment class structure to process the file for you
const attachment = new Discord.Attachment(canvas.toBuffer(), 'welcome-image.png');

channel.send(`Welcome to the server, ${member}!`, attachment);



If you are loading the file from the assets folder in the editor, that folder isn’t really a folder, it just lists all the your project files which are in the Glitch CDN, you need to get the link for the file which you want to use, and then use it in your project.


this is the link
so do i just replace wallpaper.jpg with that?


No, you will need to change the loadImage to something like this
the img.src thing


oh ok ill try that out


got it to work!!!
IM so happy


@HunterWilson56 How did you get it too work. I can’t seem to make it work.


I managed to get into contact with HunterWilson56. And he helped me fix it.