I always get error "Error: Server responded with 301" when trying to use loadImage() function.
The URL i provide in the function redirected from http to https, but instead of following the redirect, the function returned that error instead.
async run(msg, { item }) {
const canvas = Canvas.createCanvas(330, item.height);
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgb(54, 57,62)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
const iconImg = await Canvas.loadImage(item.icon); // <---
ctx.drawImage(iconImg, 0, 0);
const attachment = new Discord.MessageAttachment(canvas.toBuffer(), 'image.png');
msg.channel.send(attachment);
}
Is there any way to make that function to follow redirects for 301 redirection instead of returning that error?