Get latest attachment from the channel

akairo
loicbersier 4 years ago
parent 81a23658f9
commit 4f3270c9d5

@ -0,0 +1,11 @@
// Take latest image in the channel
module.exports = function(message) {
return message.channel.messages.fetch().then(messages => {
// Could be better
return messages.map(m => {
let attachments = (m.attachments).array();
if (attachments[0]) return attachments[0].url;
else return null;
}).filter(key => key != null)[0];
});
};
Loading…
Cancel
Save