xixi52/discord-canvas

Error: Unsupported image type

RonaldZav opened this issue · 7 comments

Error: Unsupported image type

const image = await new Canvas.Welcome()
  .setUsername(`${interaction.user.username}`)
  .setDiscriminator(`${interaction.user.discriminator}`)
  .setMemberCount(`${interaction.guild.memberCount}`)
  .setGuildName(`${interaction.guild.name}`)
  .setAvatar(`${user.displayAvatarURL({ dynamic: true, size: 256})}`)
  .setColor("border", "#ffffff")
  .setColor("username-box", "#6b6b6b")
  .setColor("discriminator-box", "#4d4d4d")
  .setColor("message-box", "#4d4d4d")
  .setColor("title", "#4d4d4d")
  .setColor("avatar", "#4d4d4d")
  .setBackground("./src/images/background.jpg")
  .toAttachment();

It gives an error with the avatar image, help.

displayAvatarURL returns a webp link

It should be a PNG. Just change the extension

It should be a PNG. Just change the extension

How do I change the extension to png?

Use : displayAvatarURL({ format: 'png' });

Use : displayAvatarURL({ format: 'png' });

Code: .setAvatar(member.user.displayAvatarURL({ format: 'png' }))

Error: Unsupported image type
    at setSource (C:\Program Files\nodejs\SuperAddon\node_modules\canvas\lib\image.js:94:13)
    at C:\Program Files\nodejs\SuperAddon\node_modules\canvas\lib\image.js:62:11
    at C:\Program Files\nodejs\SuperAddon\node_modules\simple-get\index.js:97:7
    at IncomingMessage.<anonymous> (C:\Program Files\nodejs\SuperAddon\node_modules\simple-concat\index.js:8:13)
    at Object.onceWrapper (node:events:627:28)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) uncaughtException
    ```
    
    

+1

I'm getting the same error while using .setAvatar(member.user.displayAvatarURL({ format: 'png' }))

Good evening,
It works perfectly for me, so I think a few things need to be clarified:

  1. Your Node.js version
  2. The version of the package you have
  3. Your Discord.js version.

And if possible, be shure than member.user.displayAvatarURL({ format: 'png' }) is not null or undefined and its path is valid.

You should also check if it is not the path of the background that is wrong.