首页 > 解决方案 > 我的不和谐机器人是否可以将当前聊天中的图像下载到我电脑上的目录中?

问题描述

所以,这就是我的设想,我做了一个简单的消息收集器,我希望机器人收集文件,然后将它们保存在自己的文件夹中,我是 discord.js 的新手,我很可能做错了如果我得到一些答案,会有很大帮助code example

client.on('message', inspire);

function inspire(msg) {
    if (msg.content === '?create') {
        msg.channel.send('Inspire me...');

        let filter = m => !m.author.bot;
        let collector = new Discord.MessageCollector(msg.channel, filter);
        
        collector.on('collect', colMessage);
        function colMessage(msg) {
            console.log('Feeling inspired with ' + msg.content);
            if (msg.content === "?enough") {
                collector.stop();
            }

        }
        
        collector.on('end', overWith => {
            console.log('Was inspired by ' + overWith.size + ' messages');
            const painter = Math.floor(Math.random() * artists.length);
            msg.channel.send('Here is your ' + artists[painter] + ':');

            // Artist is an array of famous painters' names, which is just there for the bot to do a funny comparison of the image it is going to send back (which is a filtered version of the image I want to download) with a masterpiece.
        });
    }
}

标签: javascriptnode.jsdiscord.jsbots

解决方案


推荐阅读