我正在尝试发送从web获取的图片
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})没有发送任何东西。当im将带有url的字符串放入文件变量时:
file: `https://something.../brawl.png`它起作用了。作为错误,我得到了以下消息:
{ (C:\Users\aspan\Documents\AmITojps\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:71:65):(C:\Users\aspan\Documents\AmITojps\node_modules\snekfetch\src\index.js:215:21) at process._tickCallback (DiscordAPIError/DiscordAPIError/next_tick.js:188:7)名称:“DiscordAPIError”,消息:“无法发送空消息”,路径:'/api/v7/channels/447351755043373056/messages',代码: 50006 }
https://stackoverflow.com/questions/50956702
复制相似问题