首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何附加文件url?

如何附加文件url?
EN

Stack Overflow用户
提问于 2018-06-20 20:40:01
回答 1查看 2.7K关注 0票数 0

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

代码语言:javascript
复制
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的字符串放入文件变量时:

代码语言:javascript
复制
    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 }

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50956702

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档