I'm trying to upload an image from a link via my Discord bot. The image is generated with PHP using Image Processing and Generation and is outputted in png format.

Although when I try and attach the image to my bots message like this it uploads a random file which I believe is the code behind the png.

message.channel.send({files: ["https://banlister.com/profiling/profile.php?id=76561198153846406"]});

I have given this a google and spent a bit of time trying to come up with other ways around this but I'm not much a fan of downloading the image each time so I thought I might be able to get some assistance here?

When I tried this with an imgur link it worked also when I linked a local image: example

I had the impression this would only be possible by downloading the image each time although I thought that I might just as well ask experts just to be sure.

1 Answers

1
PLASMA chicken On Best Solutions

The Bot sends the image as profile.phpbecuase of the url going to profile.php, so you need to specify the format. For example you can do:

message.channel.send({
  files: [{
    attachment: 'https://banlister.com/profiling/profile.php?id=76561198153846406',
    name: 'profile.png'
  }]
})