node.js Discord.js 消息附件图片

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41189796/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 17:52:15  来源:igfitidea点击:

Discord.js message attachments picture

node.jsdiscord

提问by Hong-il Yang

message.channel.sendMessage(text).attachments
["",{url:"http://openweathermap.org/img/w/"+icon+".png" }];

I made some bot, with node-js ( discord.js ).

我用node-js ( discord.js ).

I want to send message with picture(without URL) so, I found fuction attachments, in documentation. But, when I put in message (text) and attachments some picture, in the console,I get:

我想发送带有图片(没有 URL)的消息,所以,我在文档中找到了功能附件。但是,当我在控制台中输入消息(文本)和附件时,我得到:

"Cannot read property '# < Object >' of undefined"

“无法读取未定义的属性 '#<Object>'”

What should I do fix this problem?

我应该怎么做才能解决这个问题?

回答by Zaidhaan Hussain

According to the docs, you will need to pass an object containing the file URL or a FileOptionsobject. You would do this like

根据文档,您需要传递一个包含文件 URL 或FileOptions对象的对象。你会这样做

message.channel.send("some text", {
    file: "http://link.to/your.file" // Or replace with FileOptions object
});