Javascript 如何附加文件url?

Javascript 如何附加文件url?,javascript,discord.js,Javascript,Discord.js,我正在尝试发送图片我从web上获取的url: var now = new Date(); if (now.getDay() == 3 && now.getUTCHours() == 20) { var options = { method: "GET", url: `https://raw.githubusercontent.com/idaspin/DiscordAmITojpsBot/master/api/brawl_lnk.txt`,

我正在尝试发送图片我从web上获取的url

var now = new Date();
if (now.getDay() == 3 && now.getUTCHours() == 20) {
    var options = {
        method: "GET",
        url: `https://raw.githubusercontent.com/idaspin/DiscordAmITojpsBot/master/api/brawl_lnk.txt`,
        headers: {
            'User-Agent': 'nodejs request',
            'X-Key': "9qpRc8M55pFb8qDN94jH"
        }
    }
    client.channels.get("447351755043373056").send("", {
        file: "https://raw.githubusercontent.com/idaspin/DiscordAmITojpsBot/master/api/brawl.png" 
    }).then(() => {
        request(options, (error, response, body) => { // body equals "http://.../brawl.png" here
            if (!error && response.statusCode == 200) {
                client.channels.get("447351755043373056").send(`This weeks's brawl is`, {
                    file: `${body}`
                }).catch((err) => console.log(err));
            }
        })
    });
}
但是它(文件:
${body}
)不发送任何东西。当我将带有url的字符串放入文件变量时:

    file: `https://something.../brawl.png`
它起作用了。 作为错误,我收到此消息:

{DiscordAPIError:无法发送空消息 在item.request.gen.end(C:\Users\aspan\Documents\AmITojps\node\u modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:71:65) 此时(C:\Users\aspan\Documents\AmITojps\node\u modules\snekfetch\src\index.js:215:21) 在 在进程中。_tick回调(内部/process/next_tick.js:188:7) 名称:“DiscordAPIError”, 消息:“无法发送空消息”, 路径:“/api/v7/channels/447351755043373056/messages”, 代码:50006}


尝试将其作为新的不和谐附件。

<channel>.send(new Discord.Attachment("https://raw.githubusercontent.com/idaspin/DiscordAmITojpsBot/master/api/brawl.png"));
.send(新的不一致。附件(“https://raw.githubusercontent.com/idaspin/DiscordAmITojpsBot/master/api/brawl.png"));

请求(选项,(错误、响应、正文)=>{client.channels.get(“447351755043373056”).send(
本周的争吵是
,{file:
https://raw.githubusercontent.com/idaspin/DiscordAmITojpsBot/master/api/brawl.png
});})这段代码也可以工作,但我试图将${body}变量放入其中。这是我的结果:Discord无法获取原始JSON/XML文件,请尝试console.log(body)并查看它是否是JSON/XML对象,如果是,则从中获取所需数据并发送。很抱歉我误解了你原来的问题。身体等于“http://..../brawl.jpg"