1

I am using sharp and would like to make a image editing discord bot. I need to use URLs for this of course so I tried that and saw a request function in the GitHub page. However, it doesn't seem to work for me. The error is in the title here is the code:


const Discord = require("discord.js")
const sharp = require("sharp")
const client = new Discord.Client()
const url = "https://934185.smushcdn.com/2425611/wp-content/uploads/2021/05/shiba-inu-2.jpeg"

async function startup() {
    request({ url, encoding: null }, function(error, response, body) {
        if (!error) {
            sharp(body).rotate().resize(300, 300).toBuffer().then(function(data) {
                console.log(data)
            })
        }
    })
}


startup()


client.on("ready", () => {
    console.log("Ready!")
})

client.login(process.env.token)
Yaumama
  • 17
  • 6

1 Answers1

1

You need to import request into your program. To install the request module, simply type this in your console:

npm i request

Then require it in your code as such:

const request = require('request');

Even better, request is deprecated so you can use something like Axios.

https://www.npmjs.com/package/axios

codingmaster398
  • 249
  • 4
  • 14
  • Thank you so much! It is crazy that this community can answer so fast! It worked! I will mark it as an answer as soon as I can! – Yaumama Jan 21 '22 at 05:07
  • 1
    That's ok. Remember to always look these types of errors on google first before coming here. Good luck! – codingmaster398 Jan 21 '22 at 05:09