You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Haha-Yes/utils/attachment.js

11 lines
343 B
JavaScript

// 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];
});
};