diff --git a/utils/attachment.js b/utils/attachment.js new file mode 100644 index 0000000..276c103 --- /dev/null +++ b/utils/attachment.js @@ -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]; + }); +}; \ No newline at end of file