Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/471.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript [请求资源类型]:资源必须是字符串、缓冲区或有效的文件流_Javascript_Python_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript [请求资源类型]:资源必须是字符串、缓冲区或有效的文件流

Javascript [请求资源类型]:资源必须是字符串、缓冲区或有效的文件流,javascript,python,node.js,discord,discord.js,Javascript,Python,Node.js,Discord,Discord.js,我试图在图片中做一些灰度效果,但当我做命令时,它会显示上面的错误 有办法吗 代码: const jimp=require('jimp')) const{MessageAttachment}=require('discord.js') module.exports={ 姓名:'灰色', 运行:异步(客户端、消息、参数)=>{ 如果(message.attachments.size>0){ 让image=message.attachments.first().url; 如果(!image)返回; 让

我试图在图片中做一些灰度效果,但当我做命令时,它会显示上面的错误

有办法吗

代码:

const jimp=require('jimp'))
const{MessageAttachment}=require('discord.js')
module.exports={
姓名:'灰色',
运行:异步(客户端、消息、参数)=>{
如果(message.attachments.size>0){
让image=message.attachments.first().url;
如果(!image)返回;
让readedImage=等待jimp.read(图像);
让sendeImage=wait readedImage.greyscale()
让attch=newmessageattachment(sendeImage,'Skyy.png');
message.channel.send(attch);
}
}
}

在发送jimp图像之前,必须将其转换为缓冲区:

const jimp=require('jimp'))
const{MessageAttachment}=require('discord.js')
module.exports={
姓名:'灰色',
运行:异步(客户端、消息、参数)=>{
如果(message.attachments.size>0){
让image=message.attachments.first().url;
如果(!image)返回;
让readedImage=等待jimp.read(图像);
//更改了下面的行
让sendeImage=wait readedImage.greyscale().getBufferAsync();
让attch=newmessageattachment(sendeImage,'Skyy.png');
message.channel.send(attch);
}
}
}

在发送jimp图像之前,必须将其转换为缓冲区:

const jimp=require('jimp'))
const{MessageAttachment}=require('discord.js')
module.exports={
姓名:'灰色',
运行:异步(客户端、消息、参数)=>{
如果(message.attachments.size>0){
让image=message.attachments.first().url;
如果(!image)返回;
让readedImage=等待jimp.read(图像);
//更改了下面的行
让sendeImage=wait readedImage.greyscale().getBufferAsync();
让attch=newmessageattachment(sendeImage,'Skyy.png');
message.channel.send(attch);
}
}
}