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);
}
}
}