Get latest attachment from the channel
This commit is contained in:
parent
81a23658f9
commit
4f3270c9d5
1 changed files with 11 additions and 0 deletions
11
utils/attachment.js
Normal file
11
utils/attachment.js
Normal file
|
@ -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…
Reference in a new issue